Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

Need help with nested for loop

조회 수: 1 (최근 30일)
Charith Ranatunga
Charith Ranatunga 2020년 5월 17일
마감: MATLAB Answer Bot 2021년 8월 20일
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 :)

답변 (1개)

darova
darova 2020년 5월 17일
편집: darova 2020년 5월 17일
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);

이 질문은 마감되었습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by