Indexing matrix to get corresponding values for condition,store in a new matrix each time?
情報
この質問は閉じられています。 編集または回答するには再度開いてください。
古いコメントを表示
Sorry for the perhaps confusing title...
Basically I have a 3x3 matrix containing elevation angle, azimuth angle and range. I want to generate new matrices each time elevation >5 deg. There are usually about 5 segments that have this data and I want to separate each one into a new matrix.
I know how to index but not sure how to put this condition in...
Thanks
sat_tcs=llh2tcsT(sat_llh,station_llh);
sat_elev=atan2(sat_tcs(3,:),sqrt(sat_tcs(1,:).^2+sat_tcs(2,:).^2)); sat_azim=atan2(-sat_tcs(2,:),sat_tcs(1,:));
range=sqrt(sat_tcs(1,:).^2+sat_tcs(2,:).^2+sat_tcs(3,:).^2);` sat_elev(sat_elev < 5*deg2rad) = NaN;
sat_look_tcs=[sat_elev;sat_azim;range];

0 件のコメント
回答 (1 件)
David Sanchez
2014 年 8 月 22 日
It is not very clear what you want, but I think it has to be something like this:
sat_look_tcs=[sat_elev;sat_azim;range];
elev_5 = find(sat_elev >5);
sat_look_tcs_5 = zeros(length(elev_5, 3, 3)); % initialize 3D matrix to hold your submatrices
for k=1:(length(elev_5)-1)
sat_look_tcs_5(k+1,:,:) = sat_look_tcs((elev_5(k)+1):elev_5(k+1),:,:);
end
And you access your matrix with
sat_look_tcs_5(1,:,:)
sat_look_tcs_5(2,:,:)
etc...
3 件のコメント
Buzz
2014 年 8 月 22 日
Michael Haderlein
2014 年 8 月 22 日
There's a typo. It should read
sat_look_tcs_5 = zeros(length(elev_5),3,3);
I didn't check the rest of the code as I also didn't really understand the question. But maybe that's already what you need.
Buzz
2014 年 9 月 8 日
この質問は閉じられています。
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!