Re: [問題] 如何改變矩陣中數值的格式已回收
※ 引述《ABCDEFGH1 (耀)》之銘言:
先接續ABCDEFGH1版友的coding內容:
...
...
clear all;
temp_d=ones(100,30);
temp_e=ones(100,30);
for i = 1:100;
temp_e(i,:)=i*temp_d(i,:);
end
ID_bar = reshape(temp_e',3000,1);
aaa(:,1)=fix(ID_bar/100);
aaa(:,2)=mod(fix(ID_bar/10),10);
aaa(:,3)=mod(ID_bar,10);
後續slygun版友所接著寫的:
fid = fopen('testt.txt', 'w');
fprintf(fid, '%d%d%d\r\n', aaa');
fclose(fid);
簡單來說,就是把三個欄位的變數,在輸出為.txt檔案時,用%d將一個變數輸出;
如果是用%d%d%d來輸出的話,就簡單的消除了中間的空格;當然最後要記得用\r\n
來做換行的動作。
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.123.213.195
※ 編輯: susuyumi 來自: 140.123.213.195 (06/27 20:43)
→
06/27 20:45, , 1F
06/27 20:45, 1F
討論串 (同標題文章)
完整討論串 (本文為第 3 之 5 篇):