Info

La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.

Need help with nested for loop

1 visualización (últimos 30 días)
Charith Ranatunga
Charith Ranatunga el 17 de Mayo de 2020
Cerrada: MATLAB Answer Bot el 20 de Ag. de 2021
Hi Im trying to calculate slant range using two for loops, I haad some trouble creating and need some help. One paramter is elevation angle (6 elements in array) and the other is altitude (6 elements in array), and my current script just calculated 6 elements and not 36. I need to store these values in a 6 by 6 array.
altitude = [100 150 200 250 300 350];
%Altitude calculations based on Elevation angle
El_angle = [0 pi/90 pi/45 pi/30 2*pi/45 pi/18]; %0 2 4 6 8 10 deg
Height_ReRatio=((altitude+Re)/Re).^2;
slant_rang = Re*(sqrt(Height_ReRatio-((cos(El_angle)).^2))-sin(El_angle));
Any help would great, thank you in advanced :)

Respuestas (1)

darova
darova el 17 de Mayo de 2020
Editada: darova el 17 de Mayo de 2020
try bsxfun
altitude = [100 150 200 250 300 350];
%Altitude calculations based on Elevation angle
El_angle = [0 pi/90 pi/45 pi/30 2*pi/45 pi/18]; %0 2 4 6 8 10 deg
Height_ReRatio=((altitude+Re)/Re).^2;
slant_rang = bsxfun(@(x,y)Re*(sqrt(x-((cos(y)).^2))-sin(y)),Height_ReRatio(:),El_angle);

La pregunta está cerrada.

Community Treasure Hunt

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

Start Hunting!

Translated by