Borrar filtros
Borrar filtros

Calculation of Phi value in matlab

8 visualizaciones (últimos 30 días)
unknown777
unknown777 el 25 de Ag. de 2015
Comentada: unknown777 el 26 de Ag. de 2015
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.

Respuesta aceptada

maria
maria el 25 de Ag. de 2015
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

Más respuestas (1)

Image Analyst
Image Analyst el 25 de Ag. de 2015
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.

Categorías

Más información sobre Statistics and Machine Learning Toolbox en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by