Shifting a line on the x-axis ONLY

조회 수: 36 (최근 30일)
HC98
HC98 2023년 6월 7일
답변: VBBV 2023년 6월 7일
I have function
q = [0:0.01:2];
plot(20*q.^2, q.^2)
It's just a straight line. I want to move it from x = 0 to x = -50. I tried circshift but that didn't work. Any ideas?
q = [0:0.01:2];
plot(circshift(20*q.^2, -50), q.^2)
  댓글 수: 1
Simon Chan
Simon Chan 2023년 6월 7일
circshift is going to shift the position of your data, but not its value.
Why not simply -50.
q = [0:0.01:2];
plot(20*q.^2-50, q.^2)

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

채택된 답변

VBBV
VBBV 2023년 6월 7일
q = [0:0.01:2];
figure
plot(20*q.^2, q.^2)
hold on
plot(20*q.^2-50, q.^2)

추가 답변 (1개)

Shivam
Shivam 2023년 6월 7일
If I am not wrong you want to achieve something like this only right ?
You can achieve this easily by following changes in code :
q = [0:0.01:2];
plot(20*q.^2-50, q.^2)

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

제품


릴리스

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by