How to save a empty matrix during simulation.
Show older comments
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.
Answers (1)
KSSV
on 11 Aug 2017
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
Categories
Find more on Multidimensional Arrays in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!