why this error ??

1 Ansicht (letzte 30 Tage)
Kenza Boukallouch
Kenza Boukallouch am 16 Okt. 2020
Beantwortet: Image Analyst am 16 Okt. 2020
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).

Antworten (2)

Alan Stevens
Alan Stevens am 16 Okt. 2020
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
Image Analyst am 16 Okt. 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

Kategorien

Mehr zu Matrix Indexing finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by