Translate and rotate a curve
5 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
mads skibsted
le 14 Mai 2024
Réponse apportée : Mathieu NOE
le 14 Mai 2024
I have a curve as seen below:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1694241/image.jpeg)
I need to first find a new location of the curve, multiple it with two and then rotate it 180 degree, so it will end up looking similiar to the figure below (The darker curve is similiar to my curve above starting from 0,0)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1694246/image.png)
First the curve should be doubled and placed at the end of the blue curve (existing curve), then mulitple the curve with two, so it will go trough the x-axis, and then rotate 180 degrees.
Can you maybe help me with this? The data is attached.
0 commentaires
Réponse acceptée
Mathieu NOE
le 14 Mai 2024
hello Mads
like this ?
load('pqfile.MAT')
% remove NaN and correct for size mismatch
A(isnan(A)) = [];
F(isnan(F)) = [];
A = A(3:end);
A(1) = 0; % force first value to 0
% central curve
x1 = [ -A(end:-1:2); A];
y1 = [ -F(end:-1:2); F ;];
% top curve
x_rev = -0.1;
y_rev = interp1(x1,y1,x_rev);
% let's do a strech of x data (linear equation xnew = a x + b)
% for the x data
a = 1 - x_rev/max(A);
b = x_rev;
Atop = a*A + b;
% for the y data
a = 1 - y_rev/max(F);
b = y_rev;
Ftop = a*F + b;
% the bottom curve is the symmetrical of the top curve
Abot = -Atop(end:-1:1);
Fbot = -Ftop(end:-1:1);
plot(x1,y1,'k','linewidth',3);
hold on
plot(Atop,Ftop,'r');
plot(Abot,Fbot,'b');
hold off
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Surface and Mesh Plots dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!