Error using plot Invalid second data argument

조회 수: 5 (최근 30일)
Takhyung Seon
Takhyung Seon 2017년 12월 6일
댓글: Takhyung Seon 2017년 12월 6일
Hi,
I am trying to plot a vector (size 690) and I am getting the error listed above (invalid second data argument).
I extracted data from a txt file using the function textscan. I have attached the code I am using below along with the matrix and vector, Aa Rolla. I am relatively new to MATLAB and I would appreciate the help.
%orientation data for sensor a
filename = 'exampleLogfile-000.txt';
fileIDa = fopen(filename);
Aa = textscan(fileIDa, '%s %s %s %s ', 'Headerline', 5);
Rolla = Aa{1,2};
Pitcha = Aa{1,3};
Yawa = Aa{1,4};
i = 1:690;
plot(i, Rolla);
  댓글 수: 1
Takhyung Seon
Takhyung Seon 2017년 12월 6일
I have figured out that Rolla is essentially a cell array and I decided to try plot(i, Rolla{:}); Unfortunately, now I get this error (Error using plot There is no 0.117325 property on the Line class.)

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

채택된 답변

Walter Roberson
Walter Roberson 2017년 12월 6일
You are using %s formats to read your data. All of the entries are going to be character vectors. You cannot plot character vectors. Some of those %s need to be %f in the textscan()
  댓글 수: 1
Takhyung Seon
Takhyung Seon 2017년 12월 6일
Thank you so much. I have changed it to %f and plotted my data correctly.

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

추가 답변 (1개)

Roger Stafford
Roger Stafford 2017년 12월 6일
The variable 'Rolla' needs to be the same size as the 1:690 vector. You can check that by writing "size(Rolla)" in your script.

카테고리

Help CenterFile Exchange에서 Filter Design에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by