Azzera filtri
Azzera filtri

How to pick a value inside of a .mat file?

1 visualizzazione (ultimi 30 giorni)
Hey all,
I have .mat file that contains 14k double variables and their values. Also, I have a workspace that contains some of those signals and more. I want to change values of the workspace variables with the ones in the .mat file. So, how can I check if my workspace has a copy of the singal in the .mat file and change its value? And, apply it for all 14k variables respectively?
Thanks.
  5 Commenti
Hasan Kaan Tuna
Hasan Kaan Tuna il 23 Lug 2023
Can I use ismember like: ismember(MatFileWith14kVariables, ws) ? In this example ws stands for workspace. If answer is no; let's say my .mat file with 14k variables is named as FKV and, it is defined in workspace. How can I check if a variable defined in FKV is also defined in workspace? Also, how can I change that specific variable's value in workspace with the one in FKV?
Stephen23
Stephen23 il 23 Lug 2023
"Can I use ismember like: ismember(MatFileWith14kVariables, ws) ? In this example ws stands for workspace."
I see nothing in the ISMEMBER documentation to suggest that it supports a "workspace" as an input argument (whatever that means). The ISMEMBER documentation states what input arguments it supports:
But given that the word "workspace" has a very specific meaning in MATLAB:
which contradicts your explanation given here, we can only conclude that either your explanations are inaccurate or you are using standard terms to mean other things. That makes it very hard for us to help you.

Accedi per commentare.

Risposta accettata

Pratyush
Pratyush il 25 Lug 2023
Modificato: Pratyush il 25 Lug 2023
Hi Hasan,
I understand that you have some variables defined in the workspace and you want to update the variables from thier value stored in a .mat file. You only want to update those variables of your workspace which are present in your .mat file. You can use "load" function to do this. Use the following command.
% make an array of variables in your workspace
varNames = who;
% Load the specific variables from the .mat file
load('your_file.mat', varNames{:});
This would update the variables of your workspace with their value present in the .mat file and leave the variables that are not present in the .mat file unmodified.Refer to the documentation for more detail: Load variables from file into workspace.

Più risposte (0)

Prodotti


Release

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by