Shifting a line on the x-axis ONLY

36 vues (au cours des 30 derniers jours)
HC98
HC98 le 7 Juin 2023
Réponse apportée : VBBV le 7 Juin 2023
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 commentaire
Simon Chan
Simon Chan le 7 Juin 2023
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)

Connectez-vous pour commenter.

Réponse acceptée

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

Plus de réponses (1)

Shivam
Shivam le 7 Juin 2023
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)

Catégories

En savoir plus sur Creating and Concatenating Matrices dans Help Center et File Exchange

Produits


Version

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by