Dlmwrite in looping - only records the last Linha of the matrix in the text file
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hi
This is my script:
for n=1:numel(LonUq)
for m = 1:numel(LatUq)
ind = find(LLDAm(:,2) == LonUq(n) & LLDAm(:,1) == LatUq(m));
if (isempty(ind)), continue; end
p = polyfit([0; agemodel(ind)],[0; depth(ind)], 1);
idade_int(m,n) = polyval(p, 20);
a = [LatUq(m), LonUq(n), idade_int(m,n)];
disp(a);
dlmwrite('saveteste.txt', a , 'delimiter','\t', 'precision', 4 )
end
end
but when, i record txt file, appears only the last line that was executed in the cycle ( a ). While in the command window pops up all the lines.
For example:
Txt file: (a)
20.2917 -18.2617 1.5621
Command Window: (a)
30.7492 -20.0000 0.8333
20.7492 -18.6808 5.0000
20.7492 -18.5808 5.0451
30.7492 -18.5808 5.0000
20.2917 -18.2617 1.5621
20.2917 -18.2617 1.5621
Thanks
0 Kommentare
Antworten (1)
Image Analyst
am 23 Apr. 2014
Make the badly-named "a" a 2D array and put a single call to dlmwrite() AFTER the two loop s.
3 Kommentare
Image Analyst
am 25 Apr. 2014
Why are doing [(m*n), 3]???? Does that even work at all? DOesn't even look like correct syntax. Try
aa = zeros(numel(LatUq), numel(LonUq), 3); % Initialize before the loop.
Then in the loop:
aa(m, n, :) = [LatUq(m), LonUq(n), idade_int(m,n)];
Siehe auch
Kategorien
Mehr zu Get Started with MuPAD finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!