I'm trying to plot a mat file with a 1x1 structure, but it's giving the error that "Index in position 2 exceeds array bounds. Index must not exceed 1."
11 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
data1 = load('radial.mat'); % Assume data is [X1 Y1] for file1
plot(data1(:,1), data1(:,2), 'g', 'DisplayName', 'File 2');
1 Kommentar
Antworten (1)
Star Strider
am 31 Jan. 2025
Bearbeitet: Star Strider
am 31 Jan. 2025
When you load into a variable, that creates a structure. The information you want will then be in that structure.
data1 = load('radial.mat'); % Assume data is [X1 Y1] for file1
So for example if ‘data1’ defines the variable ‘radial’ (I actually have no idea what is in it, since I do not have access to it), the information you want will be in
data1.radial
The easiest way to get it would be to define:
radial = data1.radial;
That should work, and then you can execute:
figure
plot(radial(:,1), radial(:,2))
grid
Loading data into a structure is actually good practice, because you can then choose the variables you want to work with (if there are more than one in the .mat file) without filling your workspace with all of them.
.
EDIT — Corrected typographical errors.
.
13 Kommentare
Siehe auch
Kategorien
Mehr zu Spectral Estimation 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!