Updating the signal data type in .mat timeseries data

13 visualizaciones (últimos 30 días)
Upendar
Upendar el 12 de Dic. de 2025 a las 13:02
Editada: dpb el 13 de Dic. de 2025 a las 15:09
I am using Simulink Signal Editor block in Test Harness for MBD-Unit testing.
after importing test cases data(time series format) in Signal Editor block(.mat file is source file for signal data(time series format) for the Signal Editor Block), we have to open test harness each time if we want to change the data type of a signal, so I have been searching for MATLAB code that could help me change the data types of a signal directly in .mat file but no luck so far.
Can any one help me with this?
  1 comentario
dpb
dpb el 12 de Dic. de 2025 a las 13:18
Editada: dpb hace alrededor de 7 horas
"...change the data types of a signal directly in .mat file"
Can you more fully explain what you're needing and attach a (smallish) example .mat file?
If you mean to change (for example) a double to a single in a .mat file, that is only possible by reading the variable from the .mat file, converting it to whatever other datatype is desired and then re-saving it.
save will overwirte an existing variable in a .mat file with the new content, effectively changing its type, but it can't be done with a typecast() while the variable is in the file, only on a copy in memory.
Does
x=rand(10,1);
y=sqrt(x);
whos
Name Size Bytes Class Attributes x 10x1 80 double y 10x1 80 double
save test
whos -file test
Name Size Bytes Class Attributes x 10x1 80 double y 10x1 80 double
y=single(y);
save test y -append % must append or will wipe out x leaving only y
whos -file test
Name Size Bytes Class Attributes x 10x1 80 double y 10x1 40 single
do the kind of thing you're looking for?

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre View and Analyze Simulation Results en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by