Simulink From Workspace Block

1 visualizzazione (ultimi 30 giorni)
Nuh Metehan
Nuh Metehan il 5 Feb 2014
Hello I need a help,
I would like to define a Simulink input which is Sample time dependent.
For an instance; I defined a time variable-function in matlab editor and want to get values at each time step at Simulink input gate.. So i am a little bit confused how to determine this block in simulink. I think i need to used from workspace block but how to express variables ?
Can someone answer in a detailed way ?

Risposte (1)

Azzi Abdelmalek
Azzi Abdelmalek il 5 Feb 2014
Modificato: Azzi Abdelmalek il 5 Feb 2014
Example with from file block
ts=1 % your sample time
t=0:ts:100*ts % your time vector
y=sin(t) % your signal
ty=[t;y];
save FileName ty % FileName is the name of your mat-file where your signal will be saved
In Simulink set the file name to: FileName
If you want to use a from workspace block, create a variable
ts=1 % your sample time
t=0:ts:100*ts % your time vector
y=sin(t) % your signal
ty=[t;y];
ty=ty'
Then set the variable name in your block to ty and a sample time to ts.
You can also define your variable as a timeseries with from workspace block
N = 100; % number of samples
Ts = 1; % sample time
t = ((0:N)* Ts)'; % time vector
y = sin(t); % your signal
your_signal = timeseries(y,t)
Then set a variable name in your block to your_signal

Community Treasure Hunt

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

Start Hunting!

Translated by