[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Hot to do the math for plotting ?
From: |
Stephan Goldenberg |
Subject: |
Hot to do the math for plotting ? |
Date: |
Tue, 16 Jan 2018 16:50:49 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.2 |
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
- Hot to do the math for plotting ?,
Stephan Goldenberg <=