Info

Questa domanda è chiusa. Riaprila per modificarla o per rispondere.

Need help with nested for loop

1 visualizzazione (ultimi 30 giorni)
Charith Ranatunga
Charith Ranatunga il 17 Mag 2020
Chiuso: MATLAB Answer Bot il 20 Ago 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 :)

Risposte (1)

darova
darova il 17 Mag 2020
Modificato: darova il 17 Mag 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);

Questa domanda è chiusa.

Community Treasure Hunt

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

Start Hunting!

Translated by