필터 지우기
필터 지우기

"Vectors must be same length" Please help with plotting!

조회 수: 1 (최근 30일)
Stenila  Simon
Stenila Simon 2018년 8월 30일
답변: Cesar Antonio Lopez Segura 2018년 8월 30일
I'm trying to plot the following and it will not allow me to, because apparently the vectors are not the same length. What am I missing?
h = [0:1:11];
for i = 1:length(h);
T(i) = To - (6*h(i));
end
plot(h,T)
  댓글 수: 1
Stephen23
Stephen23 2018년 8월 30일
편집: Stephen23 2018년 8월 30일
Is T defined anywhere previously in the code?
Note that the square brackets are superfluous:
You possibly do not need a loop, just use this:
h = 0:11;
T = To - 6*h;

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

답변 (1개)

Cesar Antonio Lopez Segura
Cesar Antonio Lopez Segura 2018년 8월 30일
Hi,
What is the value of 'To'?
Is 'To' a scalar o vector?
The following code has not errors:
To = 0;
h = [0:1:11];
for i = 1:length(h);
T(i) = To - (6*h(i));
end
plot(h,T)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by