weird problem while copying a double value from an array into another.
古いコメントを表示
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?
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Data Type Conversion についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!