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

1 次查看(过去 30 天)
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)

采纳的回答

Simon Chan
Simon Chan 2022-3-30
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)

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Matrices and Arrays 的更多信息

产品


版本

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by