help plot of function using handle

1 vue (au cours des 30 derniers jours)
Tlotlo Oepeng
Tlotlo Oepeng le 5 Mai 2022
Commenté : Star Strider le 5 Mai 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

Réponse acceptée

Star Strider
Star Strider le 5 Mai 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 commentaires
Tlotlo Oepeng
Tlotlo Oepeng le 5 Mai 2022
Modifié(e) : Tlotlo Oepeng le 5 Mai 2022
youre the best
Star Strider
Star Strider le 5 Mai 2022
Thank you!

Connectez-vous pour commenter.

Plus de réponses (1)

Benjamin Kraus
Benjamin Kraus le 5 Mai 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])

Catégories

En savoir plus sur Line Plots dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by