how to join points on MATLAB plot

조회 수: 4 (최근 30일)
MILIND
MILIND 2011년 7월 8일
Hello, I cannot join the points with smooth line. What I get is just scattered points on the plot. What should I do to join them ? Please let me know. See below my program:
m=50;
c=2*10^3;
k=2*10^7;
%D=0.050; %D=50 mm workpiece diameter
%N=10;
Wn=sqrt(k/m);
Kc=3.5*10^8;
%%Ksp=1.4*10^13;
%lw=0.0005; %lw=0.01 mm to consider almost fresh tool. Previously it was 0.5 mm.
b=0.005; %Taking initial value of b=5 mm.
v=1.784; %v=pi*D*N/60; % %Was 1.784 mean value;
zeta=c/sqrt(4*k*m);
n=0:8;
w= input('Enter the value of chatter frequency at natural frequency in rad/sec:');
%Calculations
for w=w:1:1000
for n=1:1:9
R(w)=((Wn^2)-w^2)^2+(2*zeta*Wn)^2*w^2;
G(w)=((Wn)^2-w^2)/R(w);
H(w)=-(2*zeta*Wn*w)/R(w);
b_lim(w)=-1000/(2*Kc*G(w));
%Finding Phase angle using formulas of Altintas book
if (G(w)>0 && H(w)<0)
Psi(w)=-atan(mod(H(w),G(w)))*(180/pi);
elseif (G(w)<0 && H(w)<0)
Psi(w)=(-pi+atan(mod(H(w),G(w))))*(180/pi);
elseif (G(w)<0 && H(w)>0)
Psi(w)=(-pi-atan(mod(H(w),G(w))))*(180/pi);
elseif (G(w)>0 && H(w)>0)
Psi(w)=(-2*pi+atan(mod(H(w),G(w))))*(180/pi);
end
Theta(w)=(3*pi+2*Psi(w))*(pi/180);
T(n,w)=(2*n*pi+Theta(w))/w;
N(n,w)=60/(T(n,w));
%v=(pi*D*N(n,w))/60;
%plotting
hold on;
plot(N(n,w),b_lim(w),'-');
%hold off;
xlabel ('N in rpm');
ylabel ('b-lim in mm');
title ('Plot of b-lim vs N');
grid on;
end
end
  댓글 수: 3
Jan
Jan 2011년 7월 8일
@MILIND: Please follow David's advice. Simply open your question for editing, mark the code with the mouse and press the "{} Code" key. It takes just a second for you, but it saves a lot of time for a lot of contributors, who want to assist you.
MILIND
MILIND 2012년 1월 31일
I am putting my code again, can you help me getting a smoother plot with all scattered points connected?
%%
m=50;
c=2*10^3;
k=2*10^7;
%D=0.050; %D=50 mm workpiece diameter
%N=10;
Wn=sqrt(k/m);
Kc=3.5*10^8;
%%Ksp=1.4*10^13;
%lw=0.0005; %lw=0.01 mm to consider almost fresh tool. Previously it was 0.5 mm.
b=0.005; %Taking initial value of b=5 mm.
v=1.784; %v=pi*D*N/60; % %Was 1.784 mean value;
zeta=c/sqrt(4*k*m);
n=0:8;
w= input('Enter the value of chatter frequency at natural frequency in rad/sec:');
%Calculations
for w=w:1:1000
for n=1:1:9
R(w)=((Wn^2)-w^2)^2+(2*zeta*Wn)^2*w^2;
G(w)=((Wn)^2-w^2)/R(w);
H(w)=-(2*zeta*Wn*w)/R(w);
b_lim(w)=-1000/(2*Kc*G(w));
%Finding Phase angle using formulas of Altintas book
if (G(w)>0 && H(w)<0)
Psi(w)=-atan(mod(H(w),G(w)))*(180/pi);
elseif (G(w)<0 && H(w)<0)
Psi(w)=(-pi+atan(mod(H(w),G(w))))*(180/pi);
elseif (G(w)<0 && H(w)>0)
Psi(w)=(-pi-atan(mod(H(w),G(w))))*(180/pi);
elseif (G(w)>0 && H(w)>0)
Psi(w)=(-2*pi+atan(mod(H(w),G(w))))*(180/pi);
end
Theta(w)=(3*pi+2*Psi(w))*(pi/180);
T(n,w)=(2*n*pi+Theta(w))/w;
N(n,w)=60/(T(n,w));
%v=(pi*D*N(n,w))/60;
%plotting
hold on;
plot(N(n,w),b_lim(w),'-');
%hold off;
xlabel ('N in rpm');
ylabel ('b-lim in mm');
title ('Plot of b-lim vs N');
grid on;
end
end
%%

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

채택된 답변

Laura Proctor
Laura Proctor 2011년 7월 8일
I've gone through and vectorized your code (taken out the for loops); this will help it to run faster. The plot command now joins the points with lines.
m=50;
c=2*10^3;
k=2*10^7;
Wn=sqrt(k/m);
Kc=3.5*10^8;
b=0.005; %Taking initial value of b=5 mm.
v=1.784; %v=pi*D*N/60; % %Was 1.784 mean value;
zeta=c/sqrt(4*k*m);
n=0:8;
w= input('Enter the value of chatter frequency at natural frequency in rad/sec:');
w_vec = w:1000;
R = (Wn^2 - w_vec.^2).^2 + (2*zeta*Wn)^2 * w_vec.^2;
G = (Wn^2 - w_vec.^2).^2./R;
H = -(2*zeta*Wn*w_vec)./R;
b_lim = -1000./(2*Kc*G);
Psi = -atan(mod(H,G))*180/pi;
Psi(G<0&H<0) = -180-Psi(G<0&H<0);
Psi(G<0&H>0) = -180+Psi(G<0&H>0);
Psi(G>0&H>0) = -360-Psi(G>0&H>0);
Theta = (3*pi+2*Psi)*pi/180;
n = (1:9)';
T = (2*n*ones(1,51)*pi+ones(9,1)*Theta)./(ones(9,1)*w_vec);
N = 60./T;
plot(N,b_lim,'.-');
xlabel ('N in rpm');
ylabel ('b-lim in mm');
title ('Plot of b-lim vs N');
grid on;
  댓글 수: 2
MILIND
MILIND 2011년 7월 11일
Great effort ! But I am having an error at Line 22:
??? Error using ==> plus
Matrix dimensions must agree.
Error in ==> MATLABHelp at 22
T = (2*n*ones(1,51)*pi+ones(9,1)*Theta)./(ones(9,1)*w_vec);
can you please fix the above problem ?
Please also note that the 'input chatter frequency' is to be given 633....Thanks....
MILIND
MILIND 2012년 11월 14일
Please help me solve the error coming at line 22: T = (2*n*ones(1,51)*pi+ones(9,1)*Theta)./(ones(9,1)*w_vec);
Thanks & Regards, Milind

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

추가 답변 (1개)

MILIND
MILIND 2012년 11월 14일
Please help me solve the error coming at line 22: T = (2*n*ones(1,51)*pi+ones(9,1)*Theta)./(ones(9,1)*w_vec);
Thanks & Regards, Milind

카테고리

Help CenterFile Exchange에서 Scopes and Data Logging에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by