Getting an error "Cannot call or index into a temporary array." (Code not written by me.)
显示 更早的评论
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;
回答(1 个)
Star Strider
2020-9-11
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 个评论
Raymond McCleery
2020-9-11
Star Strider
2020-9-11
The dlmread function is not appropriate for a .xls file. Instead, use xlsread or in more recent MATLAB versions, readtable or readmatrix.
Walter Roberson
2020-9-11
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
2020-9-14
类别
在 帮助中心 和 File Exchange 中查找有关 Spreadsheets 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
