Why am i getting 'Array indices must be positive integers or logical values" when trying to plot this function?

1 view (last 30 days)
x1=linspace(asind(1/1.4),90,100)
% Defining functions for M = 1.4, alpha (a) = 1.4
f1(x1)=2*cotd(x1).*(1.4^2.*(sind(x1)).^2-1)./(1.4^2.*(1.4+cosd(2.*x1))+2)-tand(4)
f2(x1)=2*cotd(x1).*(1.4^2.*(sind(x1)).^2-1)./(1.4^2.*(1.4+cosd(2.*x1))+2)-tand(8)
f3(x1)=2*cotd(x1).*(1.4^2.*(sind(x1)).^2-1)./(1.4^2.*(1.4+cosd(2.*x1))+2)-tand(12)

Accepted Answer

Simon Chan
Simon Chan on 30 Mar 2022
Remove the x1, otherwise it becomes the index of the varaibles f1,f2 & f3 where index must be a positive integers. That's why you get an error
f1=2*cotd(x1).*(1.4^2.*(sind(x1)).^2-1)./(1.4^2.*(1.4+cosd(2.*x1))+2)-tand(4)
f2=2*cotd(x1).*(1.4^2.*(sind(x1)).^2-1)./(1.4^2.*(1.4+cosd(2.*x1))+2)-tand(8)
f3=2*cotd(x1).*(1.4^2.*(sind(x1)).^2-1)./(1.4^2.*(1.4+cosd(2.*x1))+2)-tand(12)

More Answers (0)

Categories

Find more on Matrices and Arrays in Help Center and File Exchange

Products


Release

R2021b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!