Passing Inports to output with Matlab Sim command

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)

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

C in this case is ut, required to define the inputs. xout only contains states as a function of time no inport data is coming across.
C is a structure with logicals, doubles and some are of multi-dimensions.
from help:
[t,x,y] = sim(model,timespan,options,ut);
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.

Sign in to comment.

Categories

Find more on Simulink in Help Center and File Exchange

Tags

No tags entered yet.

Asked:

on 4 Nov 2011

Community Treasure Hunt

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

Start Hunting!