What kind of loop for this equation?

Hii, In a part of my calculation i have cos (theta) /L. Theta ranges from 0 to 360 deg and L ranges from 300 to 800. But i need a calculation of l=300 ranging from0 to 360 deg,L=301 ranging from 0 to 360 deg............... L=800rangin from 0 to 360 deg.this matrix kind of calculation brings wrong loop for me.could anyone help in this regard?!

 Respuesta aceptada

Image Analyst
Image Analyst el 16 de Nov. de 2014
I have no idea if you want fixed, specified values of 300 for (the badly-named) l, and fixed specified values of 301 and 800 for L, OR if you want I to take on many (perhaps 361) values between 0 and 300, and the badly-named l to take on similar values between 0 and 360. Why does L have units of degrees anyway when it is in the denominator? Do you want this
L = 301; % Or 800 or whatever.
l = 300; % Not sure where this is even used!!!
for theta = 0 : 360
result(theta) = cosd(theta) / L;
end

2 comentarios

dinesh
dinesh el 17 de Nov. de 2014
Editada: Image Analyst el 18 de Nov. de 2014
Hi, Thanks for your response!! But my question is different from your understanding.Let me put in another way . a part of my equation is
Equ= Cos(theta)/L;
Range of Theta is 0 to 360
Range of L is 300 to 800
so my calculation of Equ involves in matrix form like
equ (1)=cos(0)/300...equ(2)=cos(0)/301....equ(800)=cos(0)/800
equ(1x1)=cos(1)/300..equ(1x2)=cos(1)/301....equ(1x800)=cos(1)/800
..........
.........
equ(360x1)=cos(360)/300...equ(360x2)=cos(360)/301...equ(360x800)=cos(360)/800
Now i need to plot the graph(L vs Theta vs Equ) in 3D. Hope i have a clear idea of my question.
Image Analyst
Image Analyst el 18 de Nov. de 2014
I think Thorsten's code will work if I understand you correctly.

Iniciar sesión para comentar.

Más respuestas (1)

Thorsten
Thorsten el 17 de Nov. de 2014
theta = 0:360; l = 300:800;
[Theta, L] = meshgrid(theta, l);
Z = cos(Theta/180*pi)./L;
mesh(theta, l, Z)

Categorías

Más información sobre MATLAB en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 16 de Nov. de 2014

Comentada:

el 18 de Nov. de 2014

Community Treasure Hunt

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

Start Hunting!

Translated by