Borrar filtros
Borrar filtros

vector tangent to curve

9 visualizaciones (últimos 30 días)
gabriella armenia
gabriella armenia el 19 de Mayo de 2018
Comentada: gabriella armenia el 23 de Mayo de 2018
Hi! i need your help.
I have to find component of a vector along the tangential direction to a curve and along the radial direction, that is orthogonal to tangential one, of course.
Then, i want to plot radial and tangential components.
this is my code:
function[f_tan_media,f_perp_media]=componenti(x,y,fx,fy)
for j=2:length(x)-1
slope(j)=(y(j+1)-y(j-1))/(x(j+1)-x(j-1));
% retta=slope(j)*(x-x(j))+y(j);
% plot(x(1:end),retta(1:end)); hold on
end
alfa=atan(slope);
beta=atan(fx./fy);
f_tan=zeros(length(fx),1);
f_perp=zeros(length(fy),1);
F = sqrt(fx.^2+fy.^2);
for i=1:length(alfa)
f_tan(i)=(F(i)*cos(alfa(i)+beta(i)));
f_perp(i)=(F(i)*sin(alfa(i)+beta(i)));
end
f_tan_media=mean(abs(f_tan));
f_perp_media=mean(abs(f_perp));
quiver(x(1:end),y(1:end),f_tan(1:end),f_perp(1:end))
for j=1:length(alfa)
u_tan(j)=(f_tan(j)*cos(alfa(j)));
v_tan(j)=(f_tan(j)*sin(alfa(j)));
end
figure;
plot(x,y,'r','LineWidth',4); hold on
quiver(x(1:5:end),y(1:5:end),u_tan(1:5:end)',v_tan(1:5:end)')
for i=1:length(alfa)
u_perp(i)=f_perp(i)*sin(alfa(i);
v_perp(i)=f_perp(i)*cos(alfa(i);
end
quiver(x(1:5:end),y(1:5:end),u_perp(1:5:end)',v_perp(1:5:end)')
legend('curva','f tan','f perp')
end
Is it ok?
Thank you so much!
  4 comentarios
John D'Errico
John D'Errico el 22 de Mayo de 2018
Editada: John D'Errico el 22 de Mayo de 2018
You seem impatient for an answer. Your code has no documentation. No hint is provided as to what fx and fy actually mean. Are they scalars? vectors? If vectors, how long are they? What do they mean in this context? Just calling them force components means nothing.
So asking someone to jump up is asking someone to make a bunch of guesses about your code, then do a thorough verification and debug of your code, despite that it seems somewhat poorly written, and do this without knowing what the code should produce and without a clear explanation of the variables.
I would point out that if a slope is S, then the slope of the line orthogonal to it is -1/S. So the use of trig functions here seems a bit of overkill. But I would only be making a wild guess about the purpose of your code.
So if you want help, then make it easy (or at least possible) for someone to help you. Explain what the code and the variables really mean. What is the context of this problem? What the code should do. What you EXPECT it to do. Otherwise, expect it to take a long time before someone makes the effort to guess correctly what the code should be doing and then figure out how it should have been written, guessing what you really expected to see.
gabriella armenia
gabriella armenia el 23 de Mayo de 2018
I'm so sorry. I didn't seem impatient. Sorry.
I would just plot tangential and radial components of F that is sqrt(fx.^2+fy.^2). fx and fy are vectors
thanks

Iniciar sesión para comentar.

Respuestas (0)

Productos


Versión

R2016b

Community Treasure Hunt

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

Start Hunting!

Translated by