How to point to actual file for LISTDLG selection?

7 views (last 30 days)
I have a list of .mat files and only one to be selected at one time. I used listdlg to select the file each time.
fd = dir('*.mat');
fn = {};
[indx,tf] = listdlg('PromptString',{'Select a file.',...
'Only one file can be selected at a time.',''},...
The above code only up to selection point.
However, when i select the required file, and using this code;
xsel = fn(indx);
xsel returned at 1x1 cell instead the actual file in .mat.
How to point the xsel to actual .mat file in directory ?
.mat file consists acceleration data (120000x1) double

Accepted Answer

Rik on 23 Feb 2023
You selected a file name. Now you need to use the load function to read the variables.
Rik on 23 Feb 2023
You're welcome, but you don't actually need struct2array, you can simply index the field of the struct.
So if the variable in the mat file is called acceleration, you can use xsel = x.acceleration;

Sign in to comment.

More Answers (0)





Community Treasure Hunt

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

Start Hunting!

Translated by