Matlab Problem Write a matlab program that asks the user to

Matlab Problem:

Write a matlab program that asks the user to enter the pressure(pa,psi,atm,torr), its current units and the desired new units to convert the value of the pressure from current units to the new desired units.

Thanks

Solution

p=input(\'enter pressure value :\')
cur=input(\'enter input units : \')
out=input(\' enter output units : \')
res=0.0
factor=1.0
if(cur==\'pa\')
if(out==\'psi\')
factor=6.8948*(10^3)
else if(out==\'atm\')
factor=1.013*(10^5)
else if(out==\'torr\')
factor=133.3224
end
if(cur==\'psi\')
if(out==\'pa\')
factor=1.450377*(10^-4)
else if(out==\'atm\')
factor=14.69595
else if(out==\'torr\')
factor=1.933678*(10^-2)
end
else if(cur==\'atm\')
if(out==\'pa\')
factor=9.8692*(10^-6)
else if(out==\'psi\')
factor=6.8046*(10^-2)
else if(out==\'torr\')
factor=1.315789*(10^-3)
end
else if(cur==\'torr\')
if(out==\'psi\')
factor=51.71493
else if(out==\'atm\')
factor=760.0
else if(out==\'pa\')
factor=7.5006*(10^-3)
end
end
res=factor*p
fprintf(\'%lf %s = %lf %s\',p,cur,res,out)

Matlab Problem: Write a matlab program that asks the user to enter the pressure(pa,psi,atm,torr), its current units and the desired new units to convert the val

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site