Filter löschen
Filter löschen

How to build onto a matrix/vector in Simulink

4 Ansichten (letzte 30 Tage)
Nhan Ngo
Nhan Ngo am 13 Mär. 2018
Kommentiert: Nhan Ngo am 13 Mär. 2018
I'm writing a function in Simulink as part of a simulation of galaxies that extracts velocity and position data and such. I have the outputs of the functions I used to arrive at that the outputs, which are scalars. I was trying to make a function that loads a matrix or vector and adds a new column every time I run a new simulation so I don't have to manually record the data at each interval. It uses the "from file" for input and "to file" for the output. I set the file initially to a vector of zeros. The code looks like this in the function.
function partoutput = particleadd(particles,x,partoutput)
partoutput(x) = particles
end
Particles is a scalar value that I have as an input. x is the iteration I am on, which is just an input block, and partoutput is the vector I am trying to add on to. When I run it, it gives me this error:
"Simulink does not support loading the input data in file 'partoutput.mat'. For data saved using MAT file versions prior to 7.3, Simulink can only load two-dimensional arrays consisting of one-dimensional, double, noncomplex samples. To load data of any other type, complexity or dimension, use a timeseries object and save the file using MAT file version 7.3 or later. For example, use: 'save file_name -v7.3 timeseries_object'."
The array is not three dimensional, and that code does not work that it suggest.
  2 Kommentare
Birdman
Birdman am 13 Mär. 2018
Can you share your model with all necessary variables?
Nhan Ngo
Nhan Ngo am 13 Mär. 2018
In the folder should be all you need. I'm using MATLAB R2017a and Simulink 8.9. The simulation looks like a mess but all you have to worry about is the function in the upper right corner. If you delete that function you can see what the output looks like.
Thanks.

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu Simulink Functions finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by