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!
