MATLAB Answers

write output to .dat file yielding repeated values

조회 수: 2(최근 30일)
fadams18
fadams18 13 Nov 2019
편집: fadams18 13 Nov 2019
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.

  댓글 수: 0

로그인 to comment.

답변(0개)

이 질문에 답변하려면 로그인을(를) 수행하십시오.


Translated by