フィルターのクリア

Calculation of Phi value in matlab

8 ビュー (過去 30 日間)
unknown777
unknown777 2015 年 8 月 25 日
コメント済み: unknown777 2015 年 8 月 26 日
width=20;
length=40;
height=10;
x=1:2:20;
y=1:4:40;
z=1:1:10;
E =length/width;
alpha=atan(E);
x1= (x.*sin(alpha)) - (y .* cos (alpha));
y1= (height./2)-z;
k= y1 ./ x1;
phi1=zeros(size(k));
for ii= 1:length(k)
if k(ii)>0
phi1(ii)= atan(k(ii)); % equation 1
else
phi1(ii)= pi-atan(k(ii)); % equation 2
end
end
Error msg : ??? Subscript indices must either be real positive integers or logicals.
Sorry. I am very noob at matlab. Please help me correct with the error. I am trying to calculate the phi1 value. When k is positive it have to use the quation 1 and when k is negative it have to use the equation 2.

採用された回答

maria
maria 2015 年 8 月 25 日
Try:
width=20;length=40;height=10;
x=1:2:20;
y=1:4:40;
z=1:1:10;
E =length/width;
alpha=atan(E);
x1= (x.*sin(alpha)) - (y .* cos (alpha));
y1= (height./2)-z;
k= y1 ./ x1;
[M,N]=size(k)
phi1=zeros(N);
for ii= 1:N
if k(ii)>0 phi1(ii)= atan(k(ii)); % equation 1 else phi1(ii)= pi-atan(k(ii)); % equation 2
end
end
  1 件のコメント
unknown777
unknown777 2015 年 8 月 26 日
Thanks....

サインインしてコメントする。

その他の回答 (1 件)

Image Analyst
Image Analyst 2015 年 8 月 25 日
This error is very well explained by the FAQ: http://matlab.wikia.com/wiki/FAQ#How_do_I_fix_the_error_.22Subscript_indices_must_either_be_real_positive_integers_or_logicals..22.3F After reading that, you will know what to do.
  1 件のコメント
unknown777
unknown777 2015 年 8 月 26 日
Thanks..

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeStatistics and Machine Learning Toolbox についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by