Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Using fwrite in MATLAB to graph constant double values in Simulink Scope blocks?

Asked by Justin Liang on 25 May 2013

I am currently trying to use UDP to send constant values from MATLAB to Simulink and then use Simulink to graph these values. Here is an image of the MATLAB code, Simulink block diagram and the graph that I am working with (note that the graph starts at a constant value of 0):

http://i.imgur.com/krkulyQ.png

In the MATLAB code I am using the fwrite function to send data to the Packet Input block which then outputs to the Scope block to graph the data. Specifically I would like to graph fractions and that is why I chose to use type double. When I run the MATLAB code the graph should jump from 0 to 50.5 as it is running in real time. However, it stays at 0.

I think there may be some problems with settings I used for the Packet Input Simulink block. Here are the settings:

http://i.imgur.com/Chc0qk8.png

I have tried this with type int8 and the graph changes according to what I input in the fwrite function. As you can see in the following image I graphed the value 50 using fwrite in int8:

http://i.imgur.com/Xzytfka.png

Here, I made changes to the "Input Packet size" and "Block output data types" since I am using int8 as shown in this image:

http://i.imgur.com/DUJ4eKB.png

If anyone knows what the problem is please let me know, thanks!

0 Comments

Justin Liang

Products

No products are associated with this question.

1 Answer

Answer by Justin Liang on 1 Jun 2013

Does anyone know how to do this?

0 Comments

Justin Liang

Contact us