This question is closed. Reopen it to edit or answer.

I have troubles to plot several functions in one diagram.

2 views (last 30 days)
I want to plot several functions and lines with different ranges (domains) in one diagram. I have a stair-step curve and to this stair-step i want to add some other curves. But it does not work. (I know the command hold on / hold off).
fplot(@(x) exp(x),[1000 1000000],'b')% this function does not work
plot([1000000,60],[9000000,60]);% straight line %does not work
And now my "special code":
clear all
Input_Matrix_Woehler = textread('2.txt')
x1 = Input_Matrix_Woehler(:,1)
y1 = Input_Matrix_Woehler(:,2)
[xb,yb] = stairs(x1,y1);
%line([100000 60], [900000 60],'Color','r','LineWidth',23);
plot([1000000,60],[9000000,60]);% straight line %does not work
hold on
figure1 = figure('Name','Woehler',...
'Color',[0.756862759590149 0.866666674613953 0.776470601558685]);
axes1 = axes('Parent',figure1);
xlim(axes1,[1000 200000000]);
grid on;
set(axes1,'Color',[0.894117653369904 0.941176474094391 0.901960790157318],...
hold on;
fplot(@(x) exp(x),[1000 1000000],'b')% this function does not work
hold off

Answers (1)

Adam on 21 Oct 2016
Edited: Adam on 21 Oct 2016
Your use of an explicit axes handle is good:
xlim(axes1,[1000 200000000]);
but why aren't you using this throughout. In particular, what exactly 'does not work' about:
This works fine for me, although it should come with an explicit axes handle to be sure of where it is being plotted. I don't know where yours will be plotted since the instruction comes before your explicit axes creation. Either it will create a new figure or just plot on whatever figure you happened to already have open and in focus last.
Your fplot code produces nothing visible because the answer is Inf for every value in the range.
Even exp(100) gives
so clearly exp evaluated between 1000 and 1000000 is going to be Inf


Community Treasure Hunt

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

Start Hunting!