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?

 Akzeptierte Antwort

Azzi Abdelmalek
Azzi Abdelmalek am 6 Jul. 2015

0 Stimmen

set(gca,'xscale','log')

2 Kommentare

Akash Agarwal
Akash Agarwal am 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 am 6 Jul. 2015
This is normal, because you have changed the x scale.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by