matlab - Modifying Iteration for Multiple Inputs -


i doing iteration find corresponding latitude/longitude @ height (h_intercept). code works single height value. however, want find lat/long of 79 heights (1x79 matrix) , therefore have output 3x79 matrix (llh_test). i've tried loop can't seem results want. doing stupid.

basically, need modify run rng_sat, u_sat , h_intercept being 1x79 matrices. needs step through entire iteration before moving next values of rng_sat, u_sat , h_intercept

also, want store of llh_test values (3x79 matrix)

rng_sat= sat_look_tcs_pass1(3,1)/2e2; u_sat=[sat_look_tcs_pass1(1,1)/sat_look_tcs_pass1(3,1);sat_look_tcs_pass1(2,1)/sat_look_tcs_pass1(3,1);sat_look_tcs_pass1(3,1)/sat_look_tcs_pass1(3,1)]; h_intercept=sat_look_pass1_llh(3,1)/2e3; h_test=0; rng_test_min=0; rng_test_max=rng_sat; err=0.01; while abs(h_test-h_intercept)>err     rng_test=(rng_test_min+rng_test_max)/2;     tcs_test=u_sat*rng_test;     llh_test=tcs2llht(tcs_test,station_llh);     h_test=llh_test(3,:);     if h_test>=h_intercept;         rng_test_max=rng_test;     else         rng_test_min=rng_test;     end end 

the easiest thing here encapsulate single for loop, , change way you're accessing core variables you're using loop index instead. looking @ code, i'm assuming sat_look_tcs_pass1 3 x 79 matrix. i'm going assume output height h_test single value because when you're doing h_test = llh_test(3,:), h_test become vector, trying of columns third row. i'm going assume single value, rather array.

to modify code, take no effort @ all, here's need modify. anywhere see %// new modified , else original code:

llh_test = zeros(3,79); %// preallocate k = 1 : 79 %// have 79 values go through     rng_sat = sat_look_tcs_pass1(3,k)/2e2; %// new change k     u_sat  = [sat_look_tcs_pass1(1,k)/sat_look_tcs_pass1(3,k); ...               sat_look_tcs_pass1(2,k)/sat_look_tcs_pass1(3,k);...               sat_look_tcs_pass1(3,k)/sat_look_tcs_pass1(3,k)]; %// new - change k     h_intercept = sat_look_pass1_llh(3,k)/2e3; %// new - change k     rng_test_min=0;     rng_test_max=rng_sat;     err=0.01;     while abs(h_test-h_intercept) > err         rng_test=(rng_test_min+rng_test_max)/2;         tcs_test=u_sat*rng_test;         llh_test(:,k) = tcs2llht(tcs_test,station_llh); %// new - llh_test matrix         h_test = llh_test(3,k); %// new - changed way accessing llh_test         if h_test >= h_intercept             rng_test_max=rng_test;         else             rng_test_min=rng_test;         end     end end  

take @ general pattern of code. changing of points accessing first column kth column. also, llh_test matrix, , each iteration in loop, want access kth column. llh_test should 3 x 79 matrix per specifications.

good luck!


Comments

Popular posts from this blog

javascript - how to protect a flash video from refresh? -

visual studio 2010 - Connect to informix database windows form application -

android - Associate same looper with different threads -