How to save a empty matrix during simulation.

While doing my simulation around 120 times in a loop. I am generating 7 data which is important for me. But some time in that 7 data 1 or 2 are empty matrix form which means it's nothing. But for saving all my data after 120 times. When I use dlmwrite('E_spct_118.txt', E_spct, '\t'); it show a an error that dimension does not match. When I check at that iteration my E_spct is 1* empty matrix. So please help me to save it so that my program does not stop in between of 120 simulation.

回答 (1 件)

KSSV
KSSV 2017 年 8 月 11 日

1 投票

As you are generating data in a loop....put a if condition, so that only non empty data will be stored and empty data gets ignored. Check the below pseudo code.
A = zeros(20,1) ;
for i = 1:20
E = rand ;
if ~isempty(E)
A(i) = E ;
end
end

カテゴリ

ヘルプ センター および File ExchangeMultidimensional Arrays についてさらに検索

質問済み:

2017 年 8 月 11 日

回答済み:

2017 年 8 月 11 日

Community Treasure Hunt

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

Start Hunting!

Translated by