Azzera filtri
Azzera filtri

How to plot a function

1 visualizzazione (ultimi 30 giorni)
Nouha Amine
Nouha Amine il 25 Mag 2022
Commentato: Sam Chak il 25 Mag 2022
Hello,
I need to plot a graph with
where x is between and ,
y is here between and ,
Can you help me with it?
Thanks

Risposta accettata

Sam Chak
Sam Chak il 25 Mag 2022
You can do something like this:
x = 0.1:0.01:10;
y1 = x.^(-2.9-0.1);
y2 = x.^(-2.9+0.1);
plot(x, y1, x, y2)
ylim([1e-8 1e0])
xlabel('x')
ylabel('y')
  2 Commenti
Nouha Amine
Nouha Amine il 25 Mag 2022
When I copied this code,
The figure didn't show up,
What is the problem with that
Sam Chak
Sam Chak il 25 Mag 2022
That's strange... I've tested the code on both MATLAB and Octave. Try adding this:
clear all
close all
x = 0.1:0.01:10;
y1 = x.^(-2.9-0.1);
y2 = x.^(-2.9+0.1);
plot(x, y1, x, y2)
ylim([1e-8 1e0])
xlabel('x')
ylabel('y')
grid on

Accedi per commentare.

Più risposte (1)

Fabio Freschi
Fabio Freschi il 25 Mag 2022
You may use fplot
figure, hold on
fplot(@(x)x.^-3,[1 1e5])
fplot(@(x)x.^-2.8,[1 1e5])
% use bi-logaritmic scale
set(gca,'YScale','log','xScale','log')

Categorie

Scopri di più su Line Plots in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by