I am trying to use imshow to take data in a .txt file and print out the image made from the data.

조회 수: 10 (최근 30일)
So far my code looks like this
a = dlmread('data.txt');
imshow(a);
But when I go to run the code I get an error saying "Error using abs too many input arguments." The .txt file has a ton of data points inside it and I made sure to save the .txt file in the same folder as my code so I am not sure why it is not able to read my data.
  댓글 수: 2
DGM
DGM 2021년 10월 26일
How is the data formatted in the text file? What is the size of a?
It would probably help to just attach the text file.
ssmith
ssmith 2021년 10월 26일
The data is formatted as (x, y, z, grayscale) The file is too large to attach the file.

댓글을 달려면 로그인하십시오.

채택된 답변

DGM
DGM 2021년 10월 26일
편집: DGM 2021년 10월 26일
I'm going to guess that this is the same homework assignment. If not, similar operations should apply. The example only shows how to rectify the image from the vectorized positional and intensity information. You'll have to figure out how to read the data from the file into the corresponding vectors and deal with the output scaling/casting as mentioned.
  댓글 수: 10
DGM
DGM 2021년 10월 27일
I don't know why you'd get an error about a function/variable called "first". There isn't anything in the code called "first".
If you don't have mat2gray(), I'm guessing you don't have Image Processing Toolbox. You can do this instead for that line:
%A = mat2gray(a(:,4)); % normalize (needs IPT)
A = normalize(a(:,4),'range'); % normalize without IPT
ssmith
ssmith 2021년 10월 27일
편집: ssmith 2021년 10월 27일
That worked! Thank you so much for your help!!!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by