Readmatrix is changing the "size" of the data I am trying to retrieve from an Excel file?
3 views (last 30 days)
Show older comments
Sort of a beginner in MatLab here.
I have a very large Excel file that I am trying to read, but I'm only concerned with two columns right now. Both columns have the exact same row range, and I should end up with a nice 6000x1 matrix. However, my second matrix (B1f) is not coming out with this size.
Please note that I'm trying to use the fillmissing command to replace all blank cells with a zero (there are a LOT of empty cells) to aid in not dealing with NaN and whatnot.
Here's the code I've got so far:
[file,filepath] = uigetfile ('*.xlsx');
file = fullfile(filepath,file);
noise = readmatrix(file,'Sheet','continuous-waveforms','Range','B2:B6001');
minValue = min(noise(:));
truezero = noise - minValue;
B1peak = readmatrix(file,'Sheet','continuous-waveforms','Range','CY2:CY6001');
B1f = fillmissing(B1peak,'constant',0);
B1ffix = B1f - truezero; %This is where the different sized matrices occur.
B1pos = B1ffix(B1ffix > 0);
MeanB1 = mean(B1pos);
I don't get any error code, just that "Matrix dimensions must agree", which, duh. My variables in the workspace window confirms the significant difference in matrix sizes.
I've been fighting with this for a while. The same thing was happening with xlsread but I tried switching to readmatrix because it seemed like a little bit better for this.
3 Comments
Walter Roberson
on 27 May 2021
You said "a very large" file; if it is more than 5 megabytes you might need to put it into Google Drive or DropBox and post the link.
I do not have Excel installed in Windows, but I could test anyhow.
Answers (1)
Sulaymon Eshkabilov
on 27 May 2021
Hi,
This is where you have logical indexing that is removing all data points which are less than 0.
B1pos = B1ffix(B1ffix > 0);
MeanB1 = mean(B1pos);
See Also
Categories
Find more on Spreadsheets in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!