Any suggestions for this code? I am attempting to make a .m file to calculate the damping curve of a shock based on % critical damping values.
7 次查看(过去 30 天)
显示 更早的评论
clc, clear
%%x=0:10;
%%y=-500:500;
%%function [cwlbs,srppi,spmr,smr,lsd,knee,hsd] = criticaldamp(x)%Removed Function and end
% EDIT PB 2/17/2017 - Edited using Walter Robertsons advise about unitsand
% While for line 29 command edit, replaced with || vs >
%%Variables
cwlbs=600;%%'corner weight'; % lbs minus unsprung for more accuracy
srppi=450;%%'spring rate' ; % lbs per inch
spmr= 0.8; %%'spring motion ratio'; % = Spring Displacement/ Wheel Displacement
smr= 0.9; %%'shock motion ratio'; % smr = Shock displacement/ Wheel Displacement
lsd=70; %%'low speed damping'; % percentage of critical
hsd=30; %%'high speed damping'; %percentage of critical
%Ride rate = K_R = (K_W * K_T)/(K_W+K_W)
knee=3; %%'location of knee';% in inch per second -switch from body to bumpctrl
%%Knee velocity usually selected above mass resonance velocity.
%%Unit Conversions
lb_f_To_N=4.448; % Unit Conversion, 1 lbf = 4.448 newtons
m_To_in=39.37; % Unit Conversion, 1 meter = 39.37 inch
lb_To_kg=0.4536; % Unit Conversion, 1 lb=0.453 kg
if spmr>1 || smr>1
disp('Motion ratios must be less than 1, but converting it for you')
%spmr=1/spmr;shmr=1/shmr;
end
wheelratestandard = srppi*spmr^2;
wheelratemetric = wheelratestandard*lb_f_To_N*m_To_in;
cd=2*sqrt(wheelratemetric*cwlbs*lb_To_kg)/lb_f_To_N/m_To_in/smr^2;
damp=lsd*cd*(0:0.1:knee);
hispeed=damp(end)+(0:0.1:20-knee)*cd*hsd;
damp=[damp hispeed(2:end)];
%%x=0:10;
%%y=-500:500;
plot(x,damp,'r','linewidth',2,'displayname',['LS:' num2str(lsd*100)...
'Knee:' num2str(knee) ' ips HS:' num2str(hsd*100) '%'])
legend('off');legend('show','location','east')
0 个评论
回答(2 个)
Walter Roberson
2017-2-17
In
p2kg=0.4536; % Unit Conversion, 1 lb=0.453 kg
you are using p for pound, but everywhere else you use the more standard lb .
m2i=39.37; % Unit Conversion, 1 meter = 39.37 inch
inches are usually abbreviated as "in"
lbf2n=4.448; % Unit Conversion, 1 lbf = 4.448 newtons
Newtons are N not n
In this name and names like m2i , it is easy to get confused about the 2 possibly meaning "squared". It would be better to use a different name such as mToin or m_To_in
if spmr>1; shmr>1; %%This is a key part that I am having problems coding
is that perhaps intended to be
if spmr>1 || shmr>1
? But if so then you cannot just invert both of them because one of them might be above 1 and the other might be below 1.
damp=lsd*cd*(0:0.1:knee);
?? knee is a string, you cannot create a vector 0:0.1:knee
0 个评论
另请参阅
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!