loading excel cell in matlab
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
mehra
il 18 Giu 2019
Risposto: Walter Roberson
il 18 Giu 2019
Hey
I am facing the 'Index exceeds matrix dimensions' Error while using xlsread
[WL_time,dummy1,dummy2]=xlsread(WL_data(nn).name,1,'B8')
Its in a for loop and nn is the counter, I define 'WL_data' as
WL_data=dir('*.xlsx')
Index exceeds matrix dimensions.
Error in Unsteady_fm50hz_150sec (line 51)
[WL_time,dummy1,dummy2]=xlsread(WL_data(nn).name,1,'B8');
I would be glad if you help me
9 Commenti
Walter Roberson
il 18 Giu 2019
Modificato: Walter Roberson
il 18 Giu 2019
Your file loaded via load(vel_data(nn).name) contains a variable named nn that is overriding the for nn loop value
You should avoid using load without an output variable:
datastruct = load(vel_data(nn).name);
Data = datastruct.Data;
Risposta accettata
Walter Roberson
il 18 Giu 2019
vel_data=dir('*.mat');
so vel_data contains information about .mat files
WL_data=dir('*.xlsx');
so WL_data contains information about .xlsx files
N1=length(WL_data);
so N1 contains the number of WL_data which is the number of .xlsx files
for nn=1:N1;
so nn is iterating over the number of .xlsx files
load(vel_data(nn).name)
but is being used to index into the .mat files, which there might be a different number of.
You should not assume that there are equal numbers of .mat and .xlsx files, and you should not assume that they will just happen to be corresponding in order. If the name of the .xlsx should exactly match the name of the .mat then you should construct the name of the .xlsx from the .mat
0 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Downloads in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!