How to add serial number and some other constant values to my output?
3 次查看(过去 30 天)
显示 更早的评论
I have an output as Text file, which has 9 outputs or 9 columns of data, i want to add serial number or step number for every entry starting from 1 and i want my Torque Field to be '-1' for all the rows and Acquistionrate_HZ to be '10' for all the rows.
Note: number of rows differ every time based on input, PFA output/notepad file
0 个评论
回答(1 个)
ANKUR KUMAR
2018-9-14
You can simple add a column at the front of your matrix and use dlmcell to write in a text file.
Suppose A is you cell matrix which contains the data which is in your .txt file.
A={'a','b','c','d','e';'f','g','h','i','j';'k','l','m','n','o';'p','q','r','s','t'}
A =
4×5 cell array
'a' 'b' 'c' 'd' 'e'
'f' 'g' 'h' 'i' 'j'
'k' 'l' 'm' 'n' 'o'
'p' 'q' 'r' 's' 't'
A=[arrayfun(@(x) num2str(x) ,[-1,1:size(A,1)-1] ,'uni',0)' A]
A =
4×6 cell array
'-1' 'a' 'b' 'c' 'd' 'e'
'1' 'f' 'g' 'h' 'i' 'j'
'2' 'k' 'l' 'm' 'n' 'o'
'3' 'p' 'q' 'r' 's' 't'
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 LaTeX 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!