필터 지우기
필터 지우기

Vectors must be the same length, Table

조회 수: 1 (최근 30일)
Amritpal Kaur
Amritpal Kaur 2016년 9월 25일
편집: Image Analyst 2016년 9월 25일
Hello,
So I have some uneven data tables like this:
And whenever I try to plot something like this:
plot(BackPocket.Ax, Ear.Ax)
I get the following error:
Vectors must be the same length.
How can I get past this by truncating, removing etc. non-matching rows?
Thanks.

채택된 답변

Image Analyst
Image Analyst 2016년 9월 25일
How can you plot Ear vs. BackPocket if they don't have the same number of elements? Do you want to plot each separately versus their index? If so
plot(BackPocket.Ax, 'b*-');
hold on;
plot(Ear.Ax, 'rd-');
  댓글 수: 2
Amritpal Kaur
Amritpal Kaur 2016년 9월 25일
No I just want to truncate the one table that has more data to match the one that has less. Any easy way to do this?
Image Analyst
Image Analyst 2016년 9월 25일
편집: Image Analyst 2016년 9월 25일
Find the number of rows and plot the min
rows = min([length(BackPocket.Ax), length(Ears.Ax)]);
plot(BackPocket(1:rows).Ax, plot(Ear(1:rows).Ax, 'b*-');
Or maybe it's
plot(BackPocket{1:rows}.Ax, plot(Ear{1:rows}.Ax, 'b*-');
Or maybe it's
plot(BackPocket.Ax(1:rows), plot(Ear.Ax(1:rows), 'b*-');
-- not sure without trying it.

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

추가 답변 (0개)

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by