MATLAB How to add trendline to semilog plot in matlab

  • Thread starter Thread starter adeeyo
  • Start date Start date
  • Tags Tags
    Matlab Plot
Click For Summary
To create a semilog plot in MATLAB using the provided x and y vectors, use the semilogx function with appropriate labels and titles. The code snippet includes commands to plot the data points and label the axes. Adding a trendline can be done by searching for "MATLAB trendline" for specific instructions. The discussion emphasizes the simplicity of the semilogx function and the ease of adding a trendline. Overall, the process is straightforward for users familiar with MATLAB.
adeeyo
Messages
20
Reaction score
0
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
Please how do I go about it?

Thanks

adeeyo
 

Attachments

  • 00560_05c.jpg
    00560_05c.jpg
    26.7 KB · Views: 1,158
Last edited by a moderator:
Physics news on Phys.org
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