필터 지우기
필터 지우기

How can I plot two vectors of different lengths ?

조회 수: 1 (최근 30일)
Luki
Luki 2017년 1월 9일
편집: Stephen23 2017년 1월 9일
I am given a vector A with size(A) = 41,1 and a vector B with size(B) = 40,1 I want create a plot with B on the y-axis and A on the x-axis. But each entry of vector B should be associated to the midpoint of two entries of vector A. So for example: A(1) = -30, A(2) = -29. In the plot I want A_plot(1) = -29.5
How can I achieve this? I was thinking about:
sz1 = size(A);
for n = 1:(sz1(1)-1)
A_plot(n) = (A(n)+ A(n+1))/2;
end
But the result is a vector of size 41,41

채택된 답변

Stephen23
Stephen23 2017년 1월 9일
편집: Stephen23 2017년 1월 9일
A_plot = (A(2:end)+A(1:end-1)) / 2;

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by