Can anyone help me with the fprintf command? I need to make a table with the given information. I put my code below.
Show older comments
clear all
close all
clc
format short
%Garrett Froula
%BsE 411
%Tire Performance Code
%Front Tire Specifications
SAF=17455; %Static Axle Load Front Axle (lbs)
bf=16.5; %Unloaded tire section width front tire (in)
Df=62.6; %Unloaded overall tire diameter front tire (in)
hf=14.025; %Tire section height front tire (in)
sF=28.4; %static loaded radius of front tire (in)
deltaf=(Df/2)-sF; %Tire deflection front tire (in)
front_t=4; %number of tires
%Rear Tire Specifications
SAR=22575; %Static Axle Load Rear Axle (lbs)
br=18.9; %Unloaded tire section width rear tire (in)
Dr=80.8; %Unloaded overall tire diameter rear tire (in)
hr=15.12; %Tire section height rear tire (in)
sR=37; %static loaded radius of rear tire (in)
deltar=(Dr/2)-sR; %Tire deflection rear tire (in)
rear_t=6; %number of tires
%Other variables
ci=174.045; %Cone Index (psi)
dbh=20.5; %Draw Bar height from ground (in)
L=118.9; %Wheel Base Length from front tire to rear tire (in)
Wstatic=40030; %Tractor Wegith (lbs)
d=1.75*dbh; %Calculation of distance from center of rear tire to end of draw bar (in)
b=72*(pi/180); %beta angle to drawbar pull
t=18*(pi/180); %alpha angle to drawbar pull
n='N/A'; %for chart purposes
slip=.1:.01:.2; %slip range of 1% to 20% in increments of 0.01
Wstf=SAF/4; %Static Tire Weight Per Tire Front Four Tires (lb)
Wstr=SAR/6; %Static Tire Weight Per Tire Rear Six Tires (lb)
c=(SAF*L)/(Wstatic); %Calculation of length from center of Mass to rear axle (in)
Wdf=Wstf; %Assign dynamic weight for front tire for first iteration (lb)
Wdr=Wstr; %Assign dynamic weight for rear tire for first iteration
Wr=Wdr;
Wf=Wdf;
Wdf=20; Wdr=20; %initialization for first iteration
fprintf('\n Tire Slip Static Tire Dynamic Tire Dimensionless Net Traction Gross Traction Tractive Efficiency \n')
fprintf('\n %% Force Force Ratio Bn Force NT Force GT %%TE\n')
for i=length(slip)
s=slip(i);
%This while looop will keep iterating until the new dynamic weight is within 1 lb of the old dynamic weight
while abs(Wf-Wdf)>1 & abs(Wr-Wdr)>1;
Wr=Wdr;
Wf=Wdf;
if Wdf<=0;
disp('error'); %This means from tires have come off the ground
end
Bnf=((ci*bf*Df)./Wf)*((1+5*(deltaf/hf))/(1+3*(bf./Df))); %ASAE Dimensionless ratio front tire
Bnr=((ci*br*Dr)./Wr)*((1+5*(deltar/hr))/(1+3*(br./Dr))); %ASAE Dimensionless ratio rear tire
NTf=Wf.*(0.88.*(1-exp(-0.1.*Bnf)).*(1-exp(-7.5.*slip))-(1./Bnf)-...
((0.5.*slip)./sqrt(Bnf))); %ASAE Net Traction front tire (lbs)
NTr=Wr.*(0.88.*(1-exp(-0.1.*Bnr)).*(1-exp(-7.5.*slip))-(1./Bnr)-...
((0.5*slip)./sqrt(Bnr))); %ASAE Net Traction rear tire (lbs)
Tr=NTr*rear_t; %Net Traction rear axle (on FBD)
Tf=NTf*front_t; %Net Traction front axle (on FBD)
Px=(NTf.*4)+(NTr.*6); %Draw Bar Pull in x-direction (lbs) (FBD eq 2)
Py=(Px./sin(b))*sin(t); %Draw Bar Pull in y-direction (lbs) (FBD eq 3)
P=sqrt(Px.^2+Py.^2); %Draw Bar Pull at 18 degrees from horizontal (lbs) (FBD eq 4)
Wdf=(((Wstatic*c)-(Py.*d)-(Px.*dbh))./(L))./front_t; %Dynamic weight for front tire (lbs) (FBD eq 5)
Wdr=(Wstatic+Py-Wf*4)./rear_t; %Dynamic weight for rear tire (lbs) (FBD eq 6)
Wdar=Wdr*rear_t; %rear axle dynamic weight
Wdaf=Wdf*front_t; %front axle dynamic weight
Wdat=Wdar+Wdaf; %Total axle dynamic weight
end
GTf=Wdf.*(0.88.*(1-exp(-0.1.*Bnf)).*(1-exp(-7.5.*slip))+0.04); %ASAE Gross traction for front tire (lbs)
GTr=Wdr.*(0.88.*(1-exp(-0.1.*Bnr)).*(1-exp(-7.5.*slip))+0.04); %ASAE Gross traction for rear tire (lbs)
GTfa=GTf*front_t; %Gross traction for front axle
GTra=GTr*rear_t; %Gross traction for rear axle
GTta=GTfa+GTra; %Total gross traction
TEf=((1-slip)*(NTf/GTf))*100; %ASAE Tractive efficiency front tire (%)
TEr=((1-slip)*(NTr/GTr))*100; %ASAE Tractive efficiency rear tire (%)
TEfa=((1-slip)*(Tf/GTfa))*100; %Tractive efficiency front axle (%)
TEra=((1-slip)*(Tr/GTra))*100; %Tractive efficiency rear axle (%)
TEtotal=((1-slip)*(Px/(GTfa+GTra)))*100; %Tractive efficiency total
fprintf('\n Front %4.1f %4.1f\n', (100*slip), Wf)
fprintf('\n Rear %4.1f %4.1f\n', (100*slip), Wr)
end
1 Comment
Lots of volunteers here are happy to help you with fprintf command. But you have to tell them what you want... do you have a question? Did you try something and it didn't work as expected? Are you missing an example of how to do something? We struggle to read peoples minds, so when you actually tell us what the problem is then we can help you.
Answers (0)
Categories
Find more on Vehicle Dynamics Blockset in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!