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

1 visualizzazione (ultimi 30 giorni)
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)

Risposta accettata

Simon Chan
Simon Chan il 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)

Più risposte (0)

Categorie

Scopri di più su Matrices and Arrays in Help Center e File Exchange

Prodotti


Release

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by