How to draw exponential function in matlab

Respuestas (2)

It seems like you listed a couple of functions, were you looking to plot them separately?
Can plot the functions using fplot
nexttile
fplot(@(x)sin(x))
nexttile
fplot(@(x)exp(-abs(x)))
Or plot values using plot
nexttile
x=linspace(-5,5,100);
plot(x,sin(x))
nexttile
plot(x,exp(-abs(x)))

8 comentarios

Chris Lin
Chris Lin el 7 de Ag. de 2021
How to merge it?
Chris Lin
Chris Lin el 7 de Ag. de 2021
I mean how to draw f(x)=sin(x). Exp(-lxl),not seperately thanks
Dave B
Dave B el 7 de Ag. de 2021
Editada: Dave B el 7 de Ag. de 2021
I'm not sure what 'merge it' means...on the same axes?
fplot(@(x)sin(x))
hold on
fplot(@(x)exp(-abs(x)))
Chris Lin
Chris Lin el 7 de Ag. de 2021
I mean how to draw f(x)=sin(x)*Exp(-lxl) thanks
Is there something in particular that's difficult about changing the equation?
fplot(@(x)sin(x).*exp(-abs(x)))
Chris Lin
Chris Lin el 11 de Ag. de 2021
what does nexttile mean?
Dave B
Dave B el 11 de Ag. de 2021
Hi Chris, can you expand on your question a bit?
Walter Roberson
Walter Roberson el 11 de Ag. de 2021
nexttile means to move to the next sub plot. It is a more modern way of using subplot() that has some advantages.

Iniciar sesión para comentar.

Chris Lin
Chris Lin el 7 de Ag. de 2021

0 votos

Thanks,How to define the area of X from minus 10 to plus 10

5 comentarios

fplot(@(x)sin(x).*exp(-abs(x)), [-10 10])
Chris Lin
Chris Lin el 8 de Ag. de 2021
Editada: Chris Lin el 8 de Ag. de 2021
How to find the integral of y(x)=sin(x)*Exp(-lxl)*exp(-i k x). Integration range from x=-10 to x=10, k=2
format long g
k = 2
k =
2
y = @(x) sin(x).*exp(-abs(x)).*exp(-i.*k.*x)
y = function_handle with value:
@(x)sin(x).*exp(-abs(x)).*exp(-i.*k.*x)
syms x
area_sym = simplify(int(y(x), x, -10, 10))
area_sym = 
double(area_sym)
ans =
0 - 0.400020854904531i
area_numeric = integral(y, -10, 10 )
area_numeric =
1.02753566831419e-17 - 0.400020854904531i
Chris Lin
Chris Lin el 8 de Ag. de 2021
How to calculate when k=1?
format long g
y = @(x,k) sin(x).*exp(-abs(x)).*exp(-i.*k.*x)
y = function_handle with value:
@(x,k)sin(x).*exp(-abs(x)).*exp(-i.*k.*x)
syms x k
area_sym = simplify(int(y(x,k), x, -10, 10))
area_sym = 
area_k_sym = simplify(subs(area_sym,k,(1:8).'))
area_k_sym = 
double(area_k_sym)
ans =
0 - 0.799941726389522i 0 - 0.400020854904531i 0 - 0.141179603605318i 0 - 0.0615282799753523i 0 - 0.0318073184754602i 0 - 0.0184532189656321i 0 - 0.0116468126495915i 0 - 0.00780451904492856i

Iniciar sesión para comentar.

Categorías

Etiquetas

Preguntada:

el 7 de Ag. de 2021

Comentada:

el 11 de Ag. de 2021

Community Treasure Hunt

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

Start Hunting!

Translated by