Why does PostSimFcn keeps throwing errors when running Parsim?
조회 수: 12 (최근 30일)
이전 댓글 표시
Hi,
I'm trying to use Parsim to run a lot of simulations. Since the logged data volume is huge, I wanted to use the PostSimFcn to process the data and only return the mean values after each run.
I set up the function in SimulationInput objects used by Parsim as shown below:
tmpin = tmpin.setPostSimFcn(@(x) postsim(x));
function newout = postsim(out)
timing_signal = out.logsout{1}.Values.Time;
power_signal = out.logsout{1}.Values.Data;
avg = trapz(timing_signal,power_signal)/180;
newout.mean = avg;
newout.p2a = max(abs(power_signal))/avg;
end
Then it throws me errors "Error executing 'PostSimFcn' on SimulationInput object. Caused by: brace indexing is not supported for variables of this type"
I then changed the code to:
function newout = postsim(out)
timing_signal = out.yout.get('power').Values.Time;
power_signal = out.yout.get('power').Values.Data;
avg = trapz(timing_signal,power_signal)/180;
newout.mean = avg;
newout.p2a = max(abs(power_signal))/avg;
end
It throws me errors "Error executing 'PostSimFcn' on SimulationInput object. Caused by: dot indexing is not supported for variables of this type"
Then I changed the simulink file to directly set an outport at the root level and changed the code to:
function newout = postsim(out)
timing_signal = out.tout;
power_signal = out.yout;
avg = trapz(timing_signal,power_signal)/180;
newout.mean = avg;
newout.p2a = max(abs(power_signal))/avg;
end
It throws me errors "Error executing 'PostSimFcn' on SimulationInput object. Caused by: X must be a vector"
I searched around the Internet and it seems nobody has mentioned this problem and the matlab documentation for setPostSimFcn doesn't mention anything but the "out" argument for the function is the copy of the SimulationOutput object. https://www.mathworks.com/help/simulink/slref/simulink.simulationinput.setpostsimfcn.html
I'm running on a linux machine with Matlab 2020a.
Can anyone provide some tips on what may be going wrong? Thanks advance
댓글 수: 3
Rahul Kumar
2022년 4월 8일
Try running in serial
out = sim(tmpin)
Put a breakpoint in the postsim function so you can debug the issue.
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Graphics Performance에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!