How to i make the equivalent of the function scatter3 from matlab into Simulink ?

1 view (last 30 days)
Hello, I am trying to plot a 3d point map using Simulink.
I have the x,y,z coordinates each as a 1 column matrix and using the function "scatter3(x,y,z);" i can plot easily the 3d point map i need. However i want to do it using simulink. I have searched on the internet and so far i didn't found anything to be useful. I am new at using Simulink so any answer helps.

Answers (1)

Walter Roberson
Walter Roberson on 19 May 2019
You can call scatter3() from a MATLAB Function Block in Simulink.
You will probably want to use persistent to remember the axes handle.
  2 Comments
Guta Florin
Guta Florin on 19 May 2019
Thank you for your answer. I have tried it and it returns the error "The matrix data must be a real, double, have two dimensions, and at least two columns. The first column must contain time values and the remaining columns the data values. Matrix values cannot be Inf or NaN.".
I use the block "from workspace" so every block x,y,z is a matrix with a single column. I have encountered also errors about time values but i have only the points coordinates.
Walter Roberson
Walter Roberson on 19 May 2019
When you use "from workspace" you are importing a timeseries. "from workspace" of a numeric array treats the first column as times, and the remaining columns as a vector of values to become available at that time. There are two settings for "from workspace": you can either use sample and hold so that the value associated with time T is held exactly as-is until the time comes around for the next time in the data -- or you can use interpolation, so at times between there is a linear interpolation of values between the times given in the data.
Remember that Simulink signals are expected to vary with time.
If you are not computing the points during simulation, then you should be asking yourself whether it is really suitable to be displaying them during simulation, or if you should instead be displaying something that was computed. Sometimes it makes sense to display something pre-computed, such as if it is serving as a background plot upon which you are going to overlay things that are computed.
Remember that MATLAB Function Block can contain load() or evalin('caller') or evalin('base')

Sign in to comment.

Products

Community Treasure Hunt

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

Start Hunting!