Correct use of Semilogx

5 views (last 30 days)
Akash Agarwal
Akash Agarwal on 6 Jul 2015
Commented: Azzi Abdelmalek on 6 Jul 2015
I have the following script:
clear all;close all; clc
x = 0:.01:50;
r=[.01, .05, 1];
for ri = 1:3
[y] = HW1_4_func(x,r(ri));
xd = y(1:50);
deltax = .01;
dy = diff(y)/deltax;
subplot (3,1,ri)
hold on
semilogx (y, 'b');
semilogx (dy, 'r');
legend ('y', 'dy');
xlabel('Time')
ylabel('Height')
caption = sprintf('R= .01 (plot 1), .5 (plot 2), and 1 (plot 3)');
title(caption, 'FontSize', 10);
end
and the following function:
function [y, dy] = HW1_4_func(x,r)
y = (1+r).*exp(x) ./ (1+r.*exp((1+r)*x));
How do I change it so that when it plots, the X-axis changes to a log scale. I tried the semilogx (y, 'b') and semilogx (dy, 'r') and nothing happens. What am I doing wrong when plotting?

Accepted Answer

Azzi Abdelmalek
Azzi Abdelmalek on 6 Jul 2015
set(gca,'xscale','log')
  2 Comments
Akash Agarwal
Akash Agarwal on 6 Jul 2015
By doing this, will this alter the graph?
When i entered in the function, it altered the graph quite a bit.
Azzi Abdelmalek
Azzi Abdelmalek on 6 Jul 2015
This is normal, because you have changed the x scale.

Sign in to comment.

More Answers (0)

Categories

Find more on Two y-axis in Help Center and File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!