How to add trendline to semilog plot in matlab

  • MATLAB
  • Thread starter adeeyo
  • Start date
  • #1
20
0

Main Question or Discussion Point

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
 

Attachments

Last edited by a moderator:

Answers and Replies

  • #2
kreil
Insights Author
Gold Member
668
67
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
 

Related Threads on How to add trendline to semilog plot in matlab

Replies
2
Views
900
  • Last Post
Replies
1
Views
52K
Replies
3
Views
4K
Replies
1
Views
3K
Replies
2
Views
42K
Replies
1
Views
3K
Replies
3
Views
2K
Replies
1
Views
2K
Replies
3
Views
4K
Top