help plot of function using handle

1 visualización (últimos 30 días)
Tlotlo Oepeng
Tlotlo Oepeng el 5 de Mayo de 2022
Comentada: Star Strider el 5 de Mayo de 2022
b1 =1
b2 =2
b3 =3
%--------Function:
G =@(k) -2*k.^2 + b1 + sqrt( (-4*k.^4 - b2*k.^2 + sqrt((-4*k.^4 - b3*k.^2).^2 + b4^2 ))/2)
%-------Grid:
k = [-2:0.01:2]
% y = bsxfun(f,x,p)
% %-------Plot
%
% figure
plot(k,G)
help code wont run

Respuesta aceptada

Star Strider
Star Strider el 5 de Mayo de 2022
Call ‘G’ with its argument —
b1 =1
b1 = 1
b2 =2
b2 = 2
b3 =3
b3 = 3
b4 = 4 % Replace Missing Value
b4 = 4
%--------Function:
G =@(k) -2*k.^2 + b1 + sqrt( (-4*k.^4 - b2*k.^2 + sqrt((-4*k.^4 - b3*k.^2).^2 + b4^2 ))/2)
G = function_handle with value:
@(k)-2*k.^2+b1+sqrt((-4*k.^4-b2*k.^2+sqrt((-4*k.^4-b3*k.^2).^2+b4^2))/2)
%-------Grid:
k = [-2:0.01:2]
k = 1×401
-2.0000 -1.9900 -1.9800 -1.9700 -1.9600 -1.9500 -1.9400 -1.9300 -1.9200 -1.9100 -1.9000 -1.8900 -1.8800 -1.8700 -1.8600 -1.8500 -1.8400 -1.8300 -1.8200 -1.8100 -1.8000 -1.7900 -1.7800 -1.7700 -1.7600 -1.7500 -1.7400 -1.7300 -1.7200 -1.7100
% y = bsxfun(f,x,p)
% %-------Plot
%
% figure
plot(k,G(k))
.
  2 comentarios
Tlotlo Oepeng
Tlotlo Oepeng el 5 de Mayo de 2022
Editada: Tlotlo Oepeng el 5 de Mayo de 2022
youre the best
Star Strider
Star Strider el 5 de Mayo de 2022
Thank you!

Iniciar sesión para comentar.

Más respuestas (1)

Benjamin Kraus
Benjamin Kraus el 5 de Mayo de 2022
An alternative approach: Use fplot.
b1 = 1;
b2 = 2;
b3 = 3;
b4 = 4;
G =@(k) -2*k.^2 + b1 + sqrt( (-4*k.^4 - b2*k.^2 + sqrt((-4*k.^4 - b3*k.^2).^2 + b4^2 ))/2);
fplot(G)
xlim([-2 2])

Categorías

Más información sobre Axes Appearance en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by