Celsius to Fahrenheit [Matlab]

Write this code in a .m file


function [ans] = convert (ti,tf)

j = 1;
for i=ti:1:tf
   tempF =  round((9 / 5 ) * i + 32);
   ans (j,1) = i;
   ans (j,2) = tempF;
j = j + 1;
end

And call this function by this line from the Command Window in your matlab


[ans] = convert (1,100)

That will convert Celsius to Fahrenheit

About these ads

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s