|
From: | Doug Stewart |
Subject: | Re: Hot to do the math for plotting ? |
Date: | Tue, 16 Jan 2018 12:34:47 -0500 |
Hi,
looks like I'm not only too numb for octave but for googleing too. I get only links to the plotting documentation.
Here's the script:
%% plot_3_functions - Plots three functions with range
%% and number of points given by user.
Interval = input('Enter interval as vector [lower upper]: ');
numPoints = input('How many points to plot: ');
x = linspace(Interval(1),Interval(2),numPoints);
F = 3.*(x).^2.-2*sin(x); % 3x^2-2sin(x)
G = sqrt(abs(x.-3)); % sqrt(|x-3|)
H = exp(-2.*x.*x); % e^(-2x^2)
plot(x,F,'x',G,'*',H,'o');
%% axis([Interval(1) Interval(2) -2 10]);
xlim([Interval(1), Interval(2)]);
ylim([-2, 10]);
xlabel("x-axis");
ylabel("y-axis");
title("Exercise 3.3.4");
legend("3x^2-2sin(x)", "sqrt(|x|)", "e^-2x^2");
%% saveas(gca,'fonctions.pdf','pdf');
I get 3 plots and the square function looks good but the Euler and Square-root functions G and H are plain wrong (checked with gnuplot).
So what am I doing wrong here ?
Regards,
Stephan
_______________________________________________
Help-octave mailing list
address@hidden
https://lists.gnu.org/mailman/listinfo/help-octave
[Prev in Thread] | Current Thread | [Next in Thread] |