Azzera filtri
Azzera filtri

CSV Write to specific column

2 visualizzazioni (ultimi 30 giorni)
Sameer Kumthekar
Sameer Kumthekar il 11 Feb 2014
Modificato: Sameer Kumthekar il 12 Feb 2014
Hello, Please find the model & expected output in the csv/excel file. What I want to do os to find out no of blocks in the model, get input output ports of each block, list them in excel/CSV, & write corrosponding I or O before each signal as shown in the fig attahced.Please help
I have written the following script
clc; %Get all blocks in side the model blks = find_system(gcb,'SearchDepth','1','LookUnderMasks','all','BlockType','SubSystem'); names = get_param(blks,'Name');
%Define & write header
header = {'Signal Name','A','B','C','D'};
xlswrite('PreDD.xls',header,'DD_Data','A1');
% lmwrite('PreDD.csv',header,0,0);
tdta = [];
inportdata = [];
outportdata = [];
index = 1;
%read data from the model
for a = 2 : size(blks)
load_system(char(blks(a)));
inports = find_system(char(blks(a)),'LookUnderMasks','all','BlockType','Inport');
outports = find_system(char(blks(a)),'LookUnderMasks','all','BlockType','Outport');
in_nms = get_param(inports,'Name');
ot_nms = get_param(outports,'Name');
inportdata = [inportdata;names(a);in_nms];
outportdata = [outportdata;names(a);ot_nms];
tdta = [tdta;in_nms;ot_nms]; %signal list of a subsystems
data = unique(tdta);
cname = inportdata(index);
cpos = strmatch(cname,header, 'exact');
rpos = strmatch(inportdata(index+1),data,'exact');
end
xlswrite('PreDD.xls',data,'DD_Data','A2');
winopen('PreDD.xls');
PLEASE NOTE THAT A TOP LEVEL SUBSYSTEM IS CREATED AS 'TEST' & SELECTING THAT SUBSYSTEM SCRIPT IS RUN.
what I am getting currently is as follows
What I required is as follows
please note that the data should appear in independent column as shown below
Please help ASAP, thanks in advance!! Sameer

Risposte (0)

Categorie

Scopri di più su Subsystems in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by