How to implement an array in simulink?

x1=round(x1,3); x1=(0:0.001:50)'; y1=amplitude*sin(2*pi*x1/25)+1.75; This is the code to generate a sinewave function.Can someone please tell me how do we do this in simulink.I tried using a sin wave block as an input but that does not work.I have tried giving the input "x1' from workspace also.

Respuestas (2)

Ameer Hamza
Ameer Hamza el 17 de Jun. de 2018

0 votos

You didn't explain what does not work with Sine wave block. See the attached Simulink model to see how to use the Sinewave block to generate the required waveform. Also look at the setting of the Sine wave block.

5 comentarios

Sanjal C C
Sanjal C C el 17 de Jun. de 2018
i am sorry i need to give an input x1 in y equation but the input is an array from 0 to 50.So how do I do that in Simulink?
In that case, try the attached Simulink model. First, run the following line and then start the simulation
t = (0:0.001:50)';
x = [t 2*pi*t/25];
Sanjal C C
Sanjal C C el 17 de Jun. de 2018
thankx a lot for your help but the model does not work
Sanjal C C
Sanjal C C el 17 de Jun. de 2018
I mean to say the attached model
Ameer Hamza
Ameer Hamza el 17 de Jun. de 2018
What is the error?

Iniciar sesión para comentar.

Sanjal C C
Sanjal C C el 17 de Jun. de 2018

0 votos

So this is the code I wanted to do it in Simulink?Can you please tell me how to do it?

4 comentarios

Ameer Hamza
Ameer Hamza el 17 de Jun. de 2018
This is exactly the same as I gave in my comment, except that now you have 3 variables. You didn't write what is not working in the Simulink model I sent.
Sanjal C C
Sanjal C C el 17 de Jun. de 2018
okay I am sorry the model is working right now but my doubt is in the image how do I input x1 values to workspace beacause I need it to use it the other function.I will attach that also.So I have attached the image which is what I need to model exactly in simulink.I used a user defined function bit it is not working.
Ameer Hamza
Ameer Hamza el 17 de Jun. de 2018
You can use several From Workspace blocks to import several variables from base workspace. Also, you can send the data back using To workspace block. You cannot directly implement a MATLAB function in Simulink. Simulink function block requires that the function should be able to process on a stream of data points because you don't know the entire data sequence in advance.
Sanjal C C
Sanjal C C el 17 de Jun. de 2018
Hi this is the small part I tried in which i tried to take the value x1 from the script and i got the corresponding error message which I had attached.

Iniciar sesión para comentar.

Etiquetas

Preguntada:

el 17 de Jun. de 2018

Comentada:

el 17 de Jun. de 2018

Community Treasure Hunt

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

Start Hunting!

Translated by