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 Exchange에서 Multidimensional 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