Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

How to add trendline to semilog plot in matlab

  1. Jan 8, 2013 #1
    Hi,
    I have x and y vectors, x=[ 90868 68151 45434 34076 27261 13631 6816 3408 2273 1948 1705 1137 853 683 569 455 342 274 228 190]; y=[ 3680 3723 3800 3866 3920 4103 4250 4320 4340 4344 4350 4364 4373 4379 4384 4393 4398 4402 4405 4407];
    I need to plot semilogx in matlab and add trendline and get the slope as shown in the image attached and also shown in this link http://img708.imageshack.us/img708/7717/0056005c.jpg [Broken]
    Please how do I go about it?

    Thanks

    adeeyo
     

    Attached Files:

    Last edited by a moderator: May 6, 2017
  2. jcsd
  3. Jan 8, 2013 #2

    kreil

    User Avatar
    Gold Member

    Hey adeeyo.

    In MATLAB, you should type or enter the following to produce the semilogx plot:

    x = [ 90868 68151 45434 34076 27261 13631 6816 3408 2273 1948 1705 1137 853 683 569 455 342 274 228 190];
    y=[ 3680 3723 3800 3866 3920 4103 4250 4320 4340 4344 4350 4364 4373 4379 4384 4393 4398 4402 4405 4407];

    h = semilogx(x,y,'*','color','black')
    xlabel('Horner Time Function - Tp=13630.0');
    ylabel('Pressure (psia)');
    title('Ex. 5-1: Semilog (Horner) Plot');

    I have to run for now but the trendline should be straightforward if you just google "matlab trendline"

    Cheers
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: How to add trendline to semilog plot in matlab
Loading...