The following code has been written by me and it is giving my result in Matlab. Can you tell how to use this code in Simulink so that I can give this as input to my switch.??
numpulses=10;
Pcell=cell(1,numpulses);
dt=.000000001;
for i=1:numpulses
T=.00000383*randn+.00000526;
W=2*T/3;
t=0:dt:T;
Pcell{i}=(t<=W);
end
pulse=[Pcell{:}];
t=(0:length(pulse)-1)*dt;
plot(t,pulse) ;
ylim([-1 2])
end

 Akzeptierte Antwort

Walter Roberson
Walter Roberson am 30 Sep. 2015

0 Stimmen

You can use a MATLAB Function Block.
It looks to me as if you would be wanting one value to be available per timestep, rather than wanting all the value to be available at the same time. See http://blogs.mathworks.com/seth/2012/02/09/using-discrete-data-as-an-input-to-your-simulink-model/

5 Kommentare

Biprasish Singha
Biprasish Singha am 1 Okt. 2015
Can you tell how to use the Matlab Function for this program. I mean what should be my input and what is my output ?? This is the output for these codes. I just want to see it in Simulink Scope.
Walter Roberson
Walter Roberson am 1 Okt. 2015
Much of your code can stay the same. However, before you make the assignment to pulse you are going to need to assign a value to pulse to hint at the type and size of pulse and you are going to have to mark it as being variable size. This is because your pulse array will not always be the same size.
Biprasish Singha
Biprasish Singha am 4 Okt. 2015
Thank you
Biprasish Singha
Biprasish Singha am 5 Okt. 2015
Sir Walter Roberson, If I want to use " From Workspace" function block, then what things I have to add in my codes ??
You would not add anything to this code. From Workspace is for the case where you have created data somehow as a MATLAB variable and want to import it to Simulink. For example after calculating your variable "pulse" you might want to make it available to Simulink.
From Workspace reads the data from the workspace of the function that Simulink was started from if you use the sim() command. If you start a Simulink model from the graphics menu, then From Workspace will read data from the 'base' workspace. You can push data into the base workspace from MATLAB by using assignin('base'), such as
assignin('base', 'pulse', pulse);

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by