Passing Inports to output with Matlab Sim command
Show older comments
In checking model results am getting the outport yout data, however I need interpolated inport data to show inputs vs outputs. Using sim command with C as a structure since I have a mix of dimensions and classes.
[tout,xout,yout]= sim('mymodel.mdl',tend,simset('OutputVariables', 'txy','SaveFormat','StructureWithTime'), C)
Have tried unsuccessfully to use signal logging. I could use a simout block, though this is a bit messy and the target environment is real time.
Answers (1)
Fangjun Jiang
on 4 Nov 2011
try
[tout,xout,yout]= sim('mymodel',tend,simset('OutputVariables', 'txy','SaveFormat','StructureWithTime'));
The argument C is not needed. The output structure with time is in xout, yout.
Update:
Make a simple example, one Inport, time a Gain of 2 and then Outport. Use default setting, enable signal logging, Input [t u], Time tout, Output yout.
t=(0:0.1:2*pi)';
u=sin(t);
sim('test');
figure(1);
plot(t,u,'r',tout,yout,'g');
[Stout,Sxout,Syout]= sim('test',10,simset('OutputVariables', 'txy','SaveFormat','StructureWithTime'));
figure(2);plot(t,u,'r',Syout.time,Syout.signals.values,'g');
C=Syout;
[Stout,Sxout,Syout]= sim('test',10,simset('OutputVariables', 'txy','SaveFormat','StructureWithTime'),C);
figure(3);plot(C.time,C.signals.values,'r',Syout.time,Syout.signals.values,'g');
2 Comments
Peter
on 4 Nov 2011
Fangjun Jiang
on 5 Nov 2011
Thank you for point it out. I was running the f14.mdl which doesn't have root level Inports.
It worked for me. See updates in my answer. Also, signal logging works too.
Categories
Find more on Simulink in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!