quick matlab question

Status
Not open for further replies.

TecHNooB

Diamond Member
Sep 10, 2005
7,458
1
76
I have an exponential curve plotted on a semilog plot. I have a linear approximation of a portion of the semilog plot. How do I superimpose the line plot on the semilog plot?
 

uec0

Junior Member
Jun 14, 2004
10
0
0
"hold on;"

If you want to mix a linear-scale plot and log-scale plot on the same figure, it gets a bit more complicated...
 

TecHNooB

Diamond Member
Sep 10, 2005
7,458
1
76
Originally posted by: uec0
"hold on;"

If you want to mix a linear-scale plot and log-scale plot on the same figure, it gets a bit more complicated...

Yea, this is what I want to do. I can still get the right answers without doing that, just need to convert some things. But then my graphs wont be... pretty :p
 

uec0

Junior Member
Jun 14, 2004
10
0
0
Doing this from memory without MATLAB here, but I think this does what you want?

% Data
x = 1 : 1 : 100;
y = exp(x);

% Figure
figure;

% Background Axes
ax1 = axes( ...
'BackgroundColor', 'w', ...
'XAxisLocation', 'bottom', 'YAxisLocation', 'left', ...
'YScale', 'log' ...
);

hold on;

plot(ax2, x, y, '-', 'Color', 'b');

% Foreground Axes
ax2 = axes( ...
'BackgroundColor', 'none', ...
'XAxisLocation', 'bottom', 'YAxisLocation', 'right', ...
'YScale', 'linear' ...
);

hold on;

plot(ax2, x, y, '-', 'Color', 'r');
 

TecHNooB

Diamond Member
Sep 10, 2005
7,458
1
76
Got another question... when I use the imagesc() function to plot a 2-D matrix, how do I change the values of the x and y axis? By default, it just keeps the index values. I want to convert those values to something else. How do I do this?
 

uec0

Junior Member
Jun 14, 2004
10
0
0
"imagesc(x, y, M);"

Try ">> doc image" or ">> doc imagesc" for more information on how to do that.
 
Status
Not open for further replies.