respected sir, if i am using syms function to calculate the value of differential equation,in result i am getting a fractional value where num and den are very large.so can you tell me how to represent these fraction in small digits.
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
ABHILASH SINGH
am 26 Sep. 2016
Beantwortet: Walter Roberson
am 26 Sep. 2016
clc;
clear all;
syms z;
lamda= input ('enter the vehicle arrival rate =');
r= input ('enter the transmission range=');
l= input ('enter the avg. road length=');
% k=lamda/l;
e=2.72;
lamda_1=lamda*r
rho=lamda_1*(e^(-lamda_1))
rho_1=e^(-lamda_1)
%%%%%%%when lambda*r>=ln(4)
a1(z)=sqrt(1-(4*rho_1*z^2))
h_1(z)=(a1(z))*((1-rho_1*rho)*z^3-(1-rho_1)*z^2-(1-rho)*z+2-rho-rho_1);
h_2(z)=e^((.5*lamda_1)*((a1(z)))-1)*(2*rho*z^3+2*rho_1*z^2-z-1+(z-1)*((a1(z))));
h_3(z)=((rho_1+rho-1)*z^3)+((1-3*rho_1-2*rho)*z^2)+((1-rho)*z)+rho_1+rho;
m_1(z)=(h_1(z)+h_2(z)+h_3(z))/((rho*(z^2))*(1+(a1(z)))-(2*z*exp((0.5*lamda_1)*(((a1(z)))-1))));
a(z)=abs(diff(m_1(z),z));
z=1;
e_noofhops(z)=abs(rho_1+2*rho+2*rho*m_1(1)+rho*a(1))
e_size=(1/(lamda*e^(-lamda*r)))-(1/lamda) %size in terms of length%
e_noofhops_l(z)=(e_noofhops(z)*l)/(e_size)
%%%%total_d(delay) is calculated by multiplying E(no. of hops)_L by the delay taken by a vehicle to transmit its message(t_h)
% t_h=input('enter the delay taken by a vehicle to transmit its message=');
% total_d=e_noofhops_l(z)*t_h;
0 Kommentare
Akzeptierte Antwort
Walter Roberson
am 26 Sep. 2016
If you want to see, for example, 3 digits for e_noofhops_l, then you could use
vpa(e_noofhops_l, 3)
or you could use
format short
double(e_noofhops_l)
(which would show 5 digits)
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Conversion Between Symbolic and Numeric finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!