How to add serial number and some other constant values to my output?

조회 수: 8 (최근 30일)
raghavendra kandukuri
raghavendra kandukuri 2018년 9월 14일
답변: ANKUR KUMAR 2018년 9월 14일
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

답변 (1개)

ANKUR KUMAR
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'

카테고리

Help CenterFile Exchange에서 Migrate GUIDE Apps에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by