Info

この質問は閉じられています。 編集または回答するには再度開いてください。

New with MatLab, need help

2 ビュー (過去 30 日間)
Thanh Cao
Thanh Cao 2018 年 4 月 10 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
I have and 2 array. - First array contains one column of a string represent data and time like this
"20122906 092315"
- Second array contains three column of number like this
55.0529719779269 54.2662719394507 84.2787929148699
55.0485478536631 54.2647888297049 84.2789499779805
55.0470731369992 54.2633057156541 84.2853886145768
55.0441236908077 54.2588563476729 84.2858596439719
55.0396994893608 54.2558900808281 84.2798920353695
I want to print these to a text file with as follow:
20122906 092315;55.05;54.26;84.27CR&LF
20122906 092317;55.05;54.26;84.27CR&LF
20122906 092397;55.05;54.26;84.27CR&LF
.....
.....
.....
20122906 092397;55.05;54.26;84.27CR&LF
EOF

回答 (1 件)

KSSV
KSSV 2018 年 4 月 10 日
str = {'20122906 092315'} ;
A = [55.0529719779269 54.2662719394507 84.2787929148699
55.0485478536631 54.2647888297049 84.2789499779805
55.0470731369992 54.2633057156541 84.2853886145768
55.0441236908077 54.2588563476729 84.2858596439719
55.0396994893608 54.2558900808281 84.2798920353695] ;
N = size(A,1) ;
str = repmat(str,N,1) ;
M = repmat(';',N,1) ;
S = repmat('CR&LF',N,1) ;
C = strcat(str,M,num2str(A(:,1)),M,num2str(A(:,2)),M,num2str(A(:,3)),S) ;
fid = fopen('data.txt','wt') ;
fprintf(fid,'%s\n',C{:}) ;
fclose(fid) ;

この質問は閉じられています。

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by