weird problem while copying a double value from an array into another.
Afficher commentaires plus anciens
Hi, I have an array like this:
magnitude=[1,1.25,1.5,1.75];
I want to copy the values in it into another matrix with this:
row=1;
inj_duration = 192;
inj_starts_at=[108,120,132,144];
for node=1:G.NodeCount
for startTime=1:4
inj_sc(row,:)=[node , magnitude(startTime) , inj_starts_at(startTime) , inj_duration];
row=row+1;
end
end
And the result became integer in the inj_sc's second column.
However, if I use something like this, no problem appears:
inj_sc=[randi(G.NodeCount,Ns,1), max_inj_conc*rand(Ns,1), randi(48,Ns,1)+inj_start_time, randi(inj_duration,Ns,1)];
The result becomes [int, double, int, int] and this is the what I want. But I can't use random numbers, I have an order for my project.
Also, If I do the following in the command line, still no problem:
inj_sc(1,2)=0.34
So, what is the problem with my nesting loops?
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Data Type Conversion dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!