Info

Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.

Need help with nested for loop

5 Ansichten (letzte 30 Tage)
Charith Ranatunga
Charith Ranatunga am 17 Mai 2020
Geschlossen: MATLAB Answer Bot am 20 Aug. 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 :)

Antworten (1)

darova
darova am 17 Mai 2020
Bearbeitet: darova am 17 Mai 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);

Diese Frage ist geschlossen.

Community Treasure Hunt

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

Start Hunting!

Translated by