write output to .dat file yielding repeated values

1 view (last 30 days)
Hello Matlabers,
I'm trying to write my output to a dat file but it apears not all the values are entered. I want the .dat file to look like this image below
Instead my .dat file looks like.
Here is my code:
clear
clc
I = 1; % counter for colums of the dat file
% variables needed to load the file that contains my Values.
nu= 50;
ps=1;
for col=[10,30,50,70] % instead of names i used Numbers because it reads
% character of my string istead of takeing the whole name.
figure_Col(I,1) = col;
% I load the values to be entered in the table below. each
% varaible contains a single value
load(['CPU_nu_',int2str(nu),'_', int2str( ps),'.mat'],'E_NeNMF_R', 'M_NeNMF_R','E_NeNMF_V','M_NeNMF_V','E_AS_V','M_AS_V','E_AS_R','M_AS_R');
% I try to assign the values to the corresponding cells of the table.
% but i guess im doing it wrongly.
figure_Col(I,2) = E_NeNMF_R;
figure_Col(I,3) = M_NeNMF_R;
figure_Col(I,5) = E_NeNMF_V;
figure_Col(I,6) = M_NeNMF_V;
figure_Col(I,8) = E_AS_R;
figure_Col(I,9) = M_AS_R;
figure_Col(I,11) = E_AS_V;
figure_Col(I,12) = M_AS_V;
I=I+1;
end
hdrs = {'Algorithm','E-step','M-step',
};
namedatfile= [int2str(nu) '_nu_' int2str(ps) '_pass.dat'];
fname = namedatfile;
txt=sprintf('%s\t',hdrs{:});
txt(end)='';
dlmwrite(fname,txt,'');
dlmwrite(fname,figure_Col,'-append','delimiter','\t');
Any help is appreciated.

Answers (0)

Community Treasure Hunt

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

Start Hunting!