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

5 vues (au cours des 30 derniers jours)
raghavendra kandukuri
raghavendra kandukuri le 14 Sep 2018
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

Réponses (1)

ANKUR KUMAR
ANKUR KUMAR le 14 Sep 2018
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'

Catégories

En savoir plus sur Migrate GUIDE Apps dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by