MATLAB Workspace To simulink Help

Status
Not open for further replies.

illegal121

Member level 2
Joined
Jun 20, 2011
Messages
49
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,288
Location
Oman
Activity points
1,650
hello There...
I want real time data view on Simulink ..
here is my code

Code:
fid=fopen('file.txt');
fseek(fid,94,'bof')
n=0;
for (n=0:6)
    pause(0.5);
    A = fgetl(fid)
    A=str2num(A)
  end
fclose(fid);

this takes line from a text file , I am just stuck that how do I update Base workspace as the loop is running ...
When I ran this it shows a variable A on workspace after the loop finishes means only last value the file reads..
But I want to read all values from file for workspace in order to interface through "from Workspace " block with simulink ...
Hope you people Helps Me Out...
Thanks A Tons ...
 

Hi
Try sim() function of Matlab to execute your model in each iteration of loop. Like
Code:
fid=fopen('file.txt');
fseek(fid,94,'bof')
n=0;
for (n=0:6)
    pause(0.5);
    A = fgetl(fid)
    A=str2num(A)
    sim('your_model');
    % Collect output here.
  end
fclose(fid);
 
thanks ALOOOt...!!
Its working...
In my scope(simulink) my values along Y axis is changing ..
Any help that how to chagne X axis of scope with the loop.. so that it looks real time
Again thank u ...
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…