Getting an error "Cannot call or index into a temporary array." (Code not written by me.)
Show older comments
This *.m file is a simple 2D line plot which I did not write. it repeatdly loads a series of Excel files and generates a *.png file of the plot. The error occurs in line 3, there are red sguiggles before both instances of "(1)". I have png files for many of the files, so I know the code worked at some point in time. As you can guess, I am a total newb at MATLAB! Code below:
file1 = dlmread("Results MSEEL 7557.xls");
Grey7557 = file1(:,3);
Depth7557 = linspace(7557,(7557+size(Grey7557)(1)*0.0016402),size(Grey7557)(1));
plot(Grey7557,Depth7557,'+')
axis("ij")
xlabel("Greyscale")
ylabel("Depth(ft)"), there are red sigules before
print -dpng Plot7557.png -S1200,1800;
Answers (1)
Star Strider
on 11 Sep 2020
If I understand the intent correctly, this should probably be:
Depth7557 = linspace(7557,(7557+size(Grey7557,1)*0.0016402),size(Grey7557,1));
such that:
size(Grey7557,1)
returns the row size of the Grey7557 vector. Since it appears to be a vector, numel would work as well, and could be more efficient.
.
4 Comments
Raymond McCleery
on 11 Sep 2020
Star Strider
on 11 Sep 2020
The dlmread function is not appropriate for a .xls file. Instead, use xlsread or in more recent MATLAB versions, readtable or readmatrix.
Walter Roberson
on 11 Sep 2020
It looks to me as if they are probably space or tab delimited files rather than actual xls files. dlmread() might be usable, if you specify R (row) as 1 .
Raymond McCleery
on 14 Sep 2020
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!