Sharing the values between vectors
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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
0 commentaires
Réponse acceptée
Andrei Bobrov
le 31 Juil 2013
Modifié(e) : Andrei Bobrov
le 31 Juil 2013
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
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Logical dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!