필터 지우기
필터 지우기

Extracting data from SimulationOutput from multiple simulations

조회 수: 2 (최근 30일)
Haroon Zafar
Haroon Zafar 2023년 12월 5일
댓글: madhan ravi 2023년 12월 6일
Hi ,
I have done parallel simuation using parsim and singl eoutput file is generated. The Simulation Output object conatibns 8 runs of the same model ( Picture 1).
Now I want to extarct data of a specific signal from all the 8 runs in into one variable.
Currently I am using something like this,. It i sworking though , but is there any better way to do it as the numebr of signal to be processed is very large.
( TP_rms is a custom function )
No_iter= 8;
PCC_V_All=[];
for k_index=1:No_iter
PCC_V = TP_rms(get(out(1, k_index).logsout,'PCC_Vabc').Values.Data);
PCC_V_All=[PCC_V_All, PCC_V];
end
PCC-V signal is 1200x3. and the output PCC_V_All would be 1200X24.
Please suggest a better way to do this.
Picture 1:
Pictuer2: ( Signals in each Simulation output- Signal names are same in each run)

채택된 답변

Paul
Paul 2023년 12월 5일
signalname = 'PCC_Vabc';
PCC_V_ALL = cell2mat(arrayfun(@(out) TP_rms(get(out.logsout,signalname).Values.Data),out,'UniformOutput',false));
There would be alternatives to fucntionalize this with signalname as an input.
  댓글 수: 3
Paul
Paul 2023년 12월 5일
You could make the whole thing into one anonymous function if you want. Not sure that would be an improvement over an m-function.
Also, I should point out that the combination of arrayfun and cell2mat in my Answer might be slower than the for loop and horizontal concatenation in @madhan ravi's Answer. If speed matters, you should compare with your typical data sets. If speed isn't the deciding factor, go with whatever you like for whatever reasons you choose.
madhan ravi
madhan ravi 2023년 12월 6일
Surely to be more fancier, you could write 'UniformOutput', false as 'un', 0.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

madhan ravi
madhan ravi 2023년 12월 5일
편집: madhan ravi 2023년 12월 5일
No_iter= 8;
PCC_V_All = cell(1, No_iter);
for k_index = 1 : No_iter
PCC_V{k_index} = TP_rms(get(out(1, k_index).logsout,'PCC_Vabc').Values.Data);
end
PCC_V_ALL = [PCC{ : }]

카테고리

Help CenterFile Exchange에서 Signal Operations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by