Shifting a line on the x-axis ONLY
조회 수: 13 (최근 30일)
이전 댓글 표시
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
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)
채택된 답변
추가 답변 (1개)
Shivam
2023년 6월 7일
If I am not wrong you want to achieve something like this only right ?
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1405144/image.png)
You can achieve this easily by following changes in code :
q = [0:0.01:2];
plot(20*q.^2-50, q.^2)
댓글 수: 0
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!