How to plot multiple graph
Mostra commenti meno recenti
Hello all
I am going to plot f= sin(5x)/x^3 and its derivative f '(x) within the domain x ∈[0.1,0.4]using semilogy plot.
6 Commenti
Image Analyst
il 21 Set 2020
OK.
the cyclist
il 21 Set 2020
Do you want two lines on the same plot, or do you want two plots (i.e. subplots).
Nima Vali
il 21 Set 2020
Ameer Hamza
il 21 Set 2020
This seems like a homework question. What have you already tried?
Nima Vali
il 21 Set 2020
Nima Vali
il 21 Set 2020
Risposte (2)
Jon
il 21 Set 2020
I don't have the symbolic toolbox, but I could get your code to work by modifying as follows. Note I did not include the line syms x as I don't have the symbolic toolbox.
x=logspace(0.1,0.4);
f =sin(5*x)./(x.^3);
Df= gradient(f)./gradient(x);
semilogx(x,f,'g')
hold on
semilogx(x,Df,'r')
grid
Ameer Hamza
il 21 Set 2020
You are using the symbolic variables incorrectly. Check this code
% clc; clear all; close all;
syms x
f(x)=sin(5*x)./(x.^3);
Df = diff(f,x);
xv = logspace(0.1,0.4);
semilogx(xv, f(xv), 'g')
hold on
semilogx(xv, Df(xv), 'r')
grid

3 Commenti
Nima Vali
il 21 Set 2020
Image Analyst
il 21 Set 2020
And you might add a legend so you know what color is what.
legend('Original Signal', 'Derivative', 'Location', 'northeast');
Nima Vali
il 21 Set 2020
Categorie
Scopri di più su Common Operations in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!