필터 지우기
필터 지우기

Sharing the values between vectors

조회 수: 2 (최근 30일)
PChoppala
PChoppala 2013년 7월 31일
Hi
I will appreciate your support on this:
I have a 3 x 9 matrix f with some finite and non-finite values. I have to manipulate f so that I will have only finite values (that is easy), and each row will have Ns finite values (as shown in temp). N is apparently divisible by Ns. Essentially, if the finite number of values in a row(s) of f is greater than Ns, they have to be adjusted amongst the other rows.
N=9; Ns=3;
f=[1,2,6,7,8,nan,nan,nan,nan;3,4,nan,nan,nan,nan,nan,nan,nan;5,9,nan,nan,nan,nan,nan,nan,nan];
temp=[1 2 6 ; 3 4 7 ; 5 9 8 ];
It could be simple, but I am now able to come up with an elegant solution. Any suggestion on how to do this?
Thank you

채택된 답변

Andrei Bobrov
Andrei Bobrov 2013년 7월 31일
편집: Andrei Bobrov 2013년 7월 31일
f =[1,2,6,7,8,nan,nan,nan,nan;
3,4,nan,nan,nan,nan,nan,nan,nan;
5,9,nan,nan,nan,nan,nan,nan,nan];
out = nan(size(f,1),Ns);
d = f(~isnan(f));
try
out(1:numel(d)) = d;
catch
msg = lasterror.message
end

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by