How should I access struct when loaded with importdata?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
I have 2 variables called 'see' and 'hear' in 'Task1.mat' file. I am loading 'Task1.mat' using 'importdata' and trying to access see and hear using the code below:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1088550/image.png)
and I am getting the following error:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1088555/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1088560/image.png)
Thank you.
1 Kommentar
dpb
am 6 Aug. 2022
I avoid importdata like the plague for just such reasons -- it does different things, depending --
In the above code snippet, everything before
task1=importdata('Task1.mat');
is irrelevant and of no value/use -- you replace all those variables immediately, anyway. Remove all that...
We can't really tell just looking at an image what's happening -- attach the .mat file or at least show what
whos -file Task1
returns before running the code with a clear workspace, then
whos task1
after.
If it were my code, and there are the two variables in the .mat file I wanted, I'd just write
load Task1
and use the two variables directly without the overhead of any struct getting in the way.
Antworten (0)
Siehe auch
Kategorien
Mehr zu Discrete-Event Simulation finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!