write output to .dat file yielding repeated values

조회 수: 1 (최근 30일)
fadams18
fadams18 2019년 11월 13일
편집: fadams18 2019년 11월 13일
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개)

카테고리

Help CenterFile Exchange에서 Spreadsheets에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by