why this error ??
Mostra commenti meno recenti
x=[-90 -90 -90 -90 -90 -45 -45 -45 -45 -45 0 0 0 0 0 45 45 45 45 45 90 90 90 90 90,45 22.5 0 -22.5 -45 45 22.5 0 -22.5 -45 45 22.5 0 -22.5 -45 45 22.5 0 -22.5 -45 45 22.5 0 -22.5 -45];
n=1;
when n<26;
f=0;
p=1/2*acosd(sqrt((1-sind(2*x(2,n))*sind(2*x(2,n)))/(1+tan(2*x(1,n))*tand(2*x(1,n)))));
ax=sqrt(1/(tand(p)*tand(p)+1));
ay= sqrt(1-ax^2);
d=acosd(tan(2*x(1,n))*sqrt((1-(sind(2*x(2,n))*sind(2*x(2,n))))/(tan(2*x(1,n))+((sind(2*x(2,n)))*(sind(2*x(2,n)))))));
f1=['simulation ',num2str(n)];
disp(f1);
f2=['ax=',num2str(ax),' ','ay=',num2str(ax),' ','d=',num2str(ax),' ','p=',num2str(p)];
disp(f2);
n = n+1;
end
Index in position 1 exceeds array bounds (must not exceed 1).
Risposte (2)
Alan Stevens
il 16 Ott 2020
0 voti
You have defined x as a 1x25 vector, but you are calling it with two arguments. You need to call it with x(n), rather than x(1,n) and x(2,n).
You probably also should use "while" rather than"when".
Image Analyst
il 16 Ott 2020
x has only one row, not two. So what value are you thinking of when you try to get the value in row 2, column n? Why do you think there should even be a x(2, n)???
Plus you must use while instead of when, or else just use a for loop
for n = 1 : 25
Categorie
Scopri di più su Matrix Indexing in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!