(simulink beginner) : cannot load a time series from workspace
7 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Hi all,
I am trying to figure out how to make some simple things work in Simulink. For example I have a matlab function which computes the position of an object given it's previous position and its velocity, as follows:
function [xnew vnew] = miModel(x,v,dt)
% x is the current position
% v is the current velocity
xnew = x + dt*velocity; % xnew is the new position
vnew = v; % new velocity =v in this example
end
I want to load the 'velocity' variable from workspace, using the 'FromWorkspace' block. I define the velocity variable in the required structure as follows:
velocity.time = [linspace(0,1,100)]'; % 100
velocity.signals.values = [0*ones(50,1); 1*ones(50,1)] ;
velocity.signals.dimensions = [1];
I construct my model as shown below..
![](https://www.mathworks.com/matlabcentral/images/broken_image.png)
or here for a fullsize image:
when I run the simulation, it does not read the values I provide;i.e., first 50 iterations with velocity 0, and the other 50 with velocity =1; Please note that I am using a simple model in 1-D (velocity and position on x-axis only). Also, since I am working in discrete time, I set my solver to 'discrete' with fixed step = 1;
Any ideas? Many thanks...from a simulink beginner M
0 Commenti
Risposta accettata
Azzi Abdelmalek
il 30 Set 2012
Modificato: Azzi Abdelmalek
il 30 Set 2012
how to set a variable from workspace
time=0:0.1:10
signal=sin(t)
variable=[time;signal]'
7 Commenti
Azzi Abdelmalek
il 1 Ott 2012
yes, since you are handling a discret process, it is better if you control the sample time. you have just to set all sample time blocks to ts, in workspace or m file you set ts= what you want.
Più risposte (1)
Vedere anche
Categorie
Scopri di più su Sources in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!