I want to plot the data as shown. but it is giving error as : Error using plot Conversion to double from cell is not possible.

조회 수: 2 (최근 30일)
fid = fopen('C:\Users\1319146\Downloads\data.txt');
textLine = fgets(fid); % Read first line.
lineCounter = 1;
while ischar(textLine)
numbers = sscanf(textLine, '%f ');
x= length(numbers);
for k = 1 : x
ca{lineCounter, k} = numbers(k);
end
textLine = fgets(fid);
lineCounter = lineCounter + 1;
end
fclose(fid);
c2 = ca(:,2);
[n,p] = size (c2);
t = 1:n;
plot(t,c2);
legend('Location 1','Location','NorthWest')
xlabel('Time'), ylabel('distance')
%c2=
[ 1.3589]
[ 7.9773]
[28.2728]
[28.2728]
[ 0]
[ 0]
[ 0]
[ 0]
[ 0]
[ 0]
[]
[ 0.8705]
[ 7.4681]
[28.2728]
[37.0303]
[ 0]
[ 0]
[ 0]
[ 0]
[ 0]
[ 0]

채택된 답변

Star Strider
Star Strider 2016년 9월 12일
I cannot run your code to test this.
See if this works:
plot(t,c2{:});
Not the curly brackets ‘{}’ in the ‘c2’ reference.
  댓글 수: 1
Sachin Patil
Sachin Patil 2016년 9월 13일
편집: Sachin Patil 2016년 9월 13일
Its working correctly. But when i increased the number of data(readings) from 21*1 to 250*1, then it is giving error as: Data must be a single matrix Y or a list of pairs X,Y

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

추가 답변 (0개)

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by