J'ai un modèle Simulink où je récupère les valeurs d'une variable dans un fichier .mat en utilisant Tofile block.
J'ai créé un script pour pouvoir récupérer que la dernière valeur du fichier .mat donc j'ai utilisé la fonction load pour charger le fichier après je ne sais pas quelle fonction à utiliser pour pouvoir récupérer ma valeur.

댓글 수: 2

KSSV
KSSV 2017년 8월 11일
Approximate translation:
I have a Simulink template where I retrieve the values of a variable in a .mat file using Tofile block.
I created a script to be able to recover the last value of the .mat file so I used the load function to load the file after I do not know what function to use to be able to retrieve my value.
Samah EL QASSAH
Samah EL QASSAH 2017년 8월 11일
thank you KSSV for the translation. I didn't notice that I express in frensh.

댓글을 달려면 로그인하십시오.

 채택된 답변

Cam Salzberger
Cam Salzberger 2017년 9월 14일

1 개 추천

Hello Samah,
It's not entirely clear to me what you are looking for. If you have a MAT file that contains an array, and you want only the last element of the array, you could do something like this:
load myMatFile.mat myArrayName
val = myArrayName(end);
If using load, it is generally good practice to specify which variables are being loaded. This allows the code to be more readable by seeing where variables originate from.
You can also use the matfile function to access the data within the MAT file, without explicitly loading all variables. This only works for numeric data, and is most efficient if the MAT file was saved with the v7.3 setting or argument.
m = matfile('myMatFile.mat');
val = m.myArrayName(end);
Hope this helps!
-Cam

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Modeling에 대해 자세히 알아보기

태그

질문:

2017년 8월 11일

답변:

2017년 9월 14일

Community Treasure Hunt

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

Start Hunting!

Translated by