Results 1 to 3 of 3

Math Help - Matlab Help: Creating M-File

  1. #1
    Junior Member
    Joined
    Jan 2010
    Posts
    38

    Matlab Help: Creating M-File

    I need help creating three M-files for the following equations so I can input the data into tables.

    Fahrenheit (Tf), Celcius (Tc), Kelvins (Tk) and Rankine (Tr)

    Tf = Tr - 459.67R

    Tf = 9/5Tc + 32F

    Tr = 9/5Tk

    I need to do this so i can make conversion tables for Fahrenheit to Kelvins, Celcius to Rankine and Celcius to Fahrenheit.

    Thanks for your help in advance!
    Follow Math Help Forum on Facebook and Google+

  2. #2
    Junior Member
    Joined
    Jan 2010
    Posts
    38
    I created the following M-Files:

    Fahrenheit_to_Kelvin
    F = input ('Enter the values for Fahrenheit:');
    Kelvin = (F + 459.67).*(5/9)


    How do I generate a table for this M-File for values 0 to 200 with increments of 20? I also need to have this transpose into two columns.

    I tried the following but continue to get errors...please help:
    Celcius_to_Rankine
    Enter values for Celcius:[0:20:200,Rankine]


    Follow Math Help Forum on Facebook and Google+

  3. #3
    Junior Member
    Joined
    Jan 2010
    Posts
    38
    I think i got it! Does this look corrent?

    >> Fahrenheit_to_Kelvin
    Enter the values for Fahrenheit:0:20:200
    Kelvin =
    Columns 1 through 5
    255.3722 266.4833 277.5944 288.7056 299.8167
    Columns 6 through 10
    310.9278 322.0389 333.1500 344.2611 355.3722
    Column 11
    366.4833

    >> Table1 = [(0:20:200)', Kelvin']
    ans =
    0 255.3722
    20.0000 266.4833
    40.0000 277.5944
    60.0000 288.7056
    80.0000 299.8167
    100.0000 310.9278
    120.0000 322.0389
    140.0000 333.1500
    160.0000 344.2611
    180.0000 355.3722
    200.0000 366.4833

    But now i have ran into a new problem:


    I have to create a table with a title, column headings and correct spacing. whenever i try this the formular ends up all messed up. this is what i type in and this is what i get in return:

    >> Fahrenheit_to_Kelvin
    Enter the values for Fahrenheit:0:20:200
    Fahrenheit to Kelvin
    Fahrenheit, F Kelvin, K
    0.00 20.00
    40.00 60.00
    80.00 100.00
    120.00 140.00
    160.00 180.00
    200.00 255.37
    266.48 277.59
    288.71 299.82
    310.93 322.04
    333.15 344.26
    355.37 366.48

    if you notice column one is doubled

    here is my M-File:

    F = input ('Enter the values for Fahrenheit:');
    Kelvin = (F + 459.67).*(5/9);

    disp(
    'Fahrenheit to Kelvin');

    disp(
    'Fahrenheit, F Kelvin, K');
    fprintf (
    '%8.2f %10.2f\n',table1)

    I just put in whatever values for the spacing, not worried about that at the moment. Any thoughts?
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. My Matlab function M-file for the Secant Method
    Posted in the Math Software Forum
    Replies: 4
    Last Post: December 3rd 2010, 06:48 AM
  2. MATLAB: Loading a file and digits
    Posted in the Math Software Forum
    Replies: 2
    Last Post: May 20th 2010, 08:55 AM
  3. templates file matlab
    Posted in the Math Software Forum
    Replies: 0
    Last Post: January 22nd 2010, 10:29 PM
  4. Need help with fsolve in Matlab M file
    Posted in the Math Software Forum
    Replies: 0
    Last Post: June 6th 2009, 03:06 PM
  5. Matlab M file
    Posted in the Math Software Forum
    Replies: 4
    Last Post: April 18th 2009, 03:34 AM

Search Tags


/mathhelpforum @mathhelpforum