How can i plot the magnitude of displacement ?

9 vues (au cours des 30 derniers jours)
Mallouli Marwa
Mallouli Marwa le 19 Mai 2016
Commenté : Walter Roberson le 19 Mai 2016
Hi, i want to plot the magnitude of displacement x(:,1) and i have this program but the curve displacement =f(rload) mentioned is false. Can someone help me please.
function xdot = equacte(t,x)
% Function file for mass with spring.
% Position is first variable, velocity is second variable,load is the third variable
freq=100; %frequency (Hz)
w=2*pi*freq;
m=0.0112;
k=262.8257 ;
teta =-4.40e+03;
cp= 1.8492*10^-7;
%fre=100/(2*pi);
%tandelta=(-4.5235*10^-6)*fre^2 +0.001*fre + 0.13556;
%rload=tandelta/(100*cp)
for rload =0:20:50000
A = [0,1,0;-k/m,0,-teta/m;(-teta/rload),0,-1/(rload*cp)];
B = [0;1/m;0];
f =sin(w*t);
xdot = A*x+B*f;
end
end
d31=-320*10^-12;
y11e= 62*10^9;
e33sig= 33.65*10^-9;
rop= 7800;
tp= 0.1905*10^-3;
lp= 50.8*10^-3;
bp= 25.4*10^-3;
l1= 6.35*10^-3;
l2= 44.45*10^-3;
k31carre= ((d31^2)*y11e)/e33sig;
y11d = y11e /(1-k31carre);
e33eps = e33sig*(1-k31carre);
ap = lp*bp;
cp = (e33eps*ap)/tp;
%%%%%%%%%%%%%%%%%%% beam %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
yb = 69*10^9;
rob= 2700;
tb=0.79375*10^-3;
lb=152.4*10^-3;
mtip=0.01;
bb=25.4*10^-3;
%%%%%%%%%%%%%%%%%calcul des termes de l'equation de mvt%%%%%%%%%%%%%%%%%%%
k= ((yb*bb*tb^3)/lb^3 )+( (8*y11d*bp*(l2^3-l1^3)*(((tb/2)+tp)^3-(tb/2)^3)) / lb^6);
teta=( 3*d31*y11e*bp*tp*(tb+tp)*(l2^2-l1^2) )/(lb^3*cp*tp);
m= ((rob*bb*tb*lb)/7)+((2*rop*bp*tp*(l2^7-l1^7))/(7*lb^6))+mtip;
[t,x]=ode45(@equacte,[0:0.0004:1],[0,0,0]);
index=1;
for rload=0:20:50000
if(x(index,1)>=0)
fg=x(index,1);
else
fg=abs(x(index,1));
end
fk(index)=fg;
index= index + 1;
end
figure;
plot([0:20:50000],fk,'r')
xlabel('rload(Ohm)');
ylabel('displacement(m)');

Réponse acceptée

Walter Roberson
Walter Roberson le 19 Mai 2016
Your code has
for rload=0:20:50000
but you do not use the value of rload anywhere in your code.
Note: that loop could be replaced by just
fk = abs(x(:,1));
  2 commentaires
Mallouli Marwa
Mallouli Marwa le 19 Mai 2016
Modifié(e) : Walter Roberson le 19 Mai 2016
I have chaged this for loop by this :
Please correct it
index = 1;
for i=0:20:50000
xm =max(x(index,1))-min (x(index,1))
xk(index) = xm;
index = index + 1;
end
figure;
plot([0:20:50000],xk,'b')
xlabel('rload(Ohm)');
ylabel('magnitude of displacement(m))');
Walter Roberson
Walter Roberson le 19 Mai 2016
x(index,1) is a scalar, so min() and max() of it are the same values, so your xm is always going to be 0.
What is wrong with
plot([0:20:50000], abs(x(:,1)), 'b')
?

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Resizing and Reshaping Matrices dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by