Industriële fabricage
Industrieel internet der dingen | Industriële materialen | Onderhoud en reparatie van apparatuur | Industriële programmering |
home  MfgRobots >> Industriële fabricage >  >> Industrial programming >> MATLAB

Functies Plotten in MATLAB: Stapsgewijze Handleiding

Om een functie te plotten, volg deze stappen:

  1. Definieer x met het bereik van waarden
  2. Definieer de functie y = f(x)
  3. Roep plot(x, y) aan

Basiscvoorbeelden

Lineaire Functie: y = x

x = [0:5:100];
y = x;
plot(x, y)

Kwadratische Functie: y = x²

Grovere stap (20):

x = [-100:20:100];
y = x.^2;
plot(x, y)

Fijnere stap (5) voor gladder resultaat:

x = [-100:5:100];
y = x.^2;
plot(x, y)

Grafiek Verbeteren: Titels, Labels, Grid, Schaling

  • xlabel, ylabel - as labels
  • title - grafiektitel
  • grid on - roosterlijnen
  • axis equal - gelijke schaling op beide assen
  • axis square - vierkante plot

Voorbeeld: Sinusfunctie

x = [0:0.01:10];
y = sin(x);
plot(x, y), xlabel('x'), ylabel('Sin(x)'), title('Sin(x) Grafiek'), grid on, axis equal

Meerdere Functies op Één Grafiek

x = [0:0.01:10];
y = sin(x);
g = cos(x);
plot(x, y, x, g, '.-'), legend('Sin(x)', 'Cos(x)')

Kleuren Instellen

MATLAB biedt 8 basiskleuren:

CodeKleur
wWit
kZwart
bBlauw
rRood
cCyaan
gGroen
mMagenta
yGeel

Voorbeeld: Twee Polynomen

x = [-10:0.01:10];
y = 3*x.^4 + 2*x.^3 + 7*x.^2 + 2*x + 9;
g = 5*x.^3 + 9*x + 2;
plot(x, y, 'r', x, g, 'g')

As Schalen Instellen

axis([xmin xmax ymin ymax])

Voorbeeld

x = [0:0.01:10];
y = exp(-x).*sin(2*x + 3);
plot(x, y), axis([0 10 -1 1])

Subplots Maken

subplot(m, n, p) creëert een array van m×n plots, p specificeert welke plot.

Voorbeeld: Twee Gedempte Sinussen

x = [0:0.01:5];
y = exp(-1.5*x).*sin(10*x);
subplot(1,2,1)
plot(x,y), xlabel('x'), ylabel('exp(-1.5x)*sin(10x)'), axis([0 5 -1 1])

y = exp(-2*x).*sin(10*x);
subplot(1,2,2)
plot(x,y), xlabel('x'), ylabel('exp(-2x)*sin(10x)'), axis([0 5 -1 1])

MATLAB

  1. MATLAB: Uitgebreid Overzicht van een Leidende Numerieke Rekenomgeving
  2. MATLAB Basics: Essentiële Syntax & Commando's
  3. Variabelen in MATLAB Begrijpen: Basis en Voorbeelden
  4. Essentiële MATLAB Commando's voor Efficiënte Berekening
  5. MATLAB Datatypes: Uitgebreide Gids
  6. MATLAB Operatoren: Complete Gids voor Rekenkundige, Logische en Bitwise Operaties
  7. MATLAB Vectoren: Basis van Rij- en Kolomvectoren
  8. MATLAB Matrix Basis: Data Aanmaken, Benaderen en Manipuleren
  9. MATLAB: Multidimensionale en Speciale Arrays Beheersen
  10. MATLAB Dubbele Punt Notatie: Vectors Maken & Efficiënt Itereren
  11. MATLAB Getallen: Typen, Opslag en Conversie