Please help me, I want to graph this attached simple relation

3 vues (au cours des 30 derniers jours)
Tarek
Tarek le 19 Juil 2025
Modifié(e) : Matt J le 22 Juil 2025
  3 commentaires
Torsten
Torsten le 19 Juil 2025
Modifié(e) : Torsten le 19 Juil 2025
Define the constants.
Define X (e.g. as X = -6:0.0001:6) .
Define phi.
Use plot(X,phi) to plot.
To get used to MATLAB, you should pass MATLAB Onramp - a course free of costs to learn the basics of the new software:
Torsten
Torsten le 20 Juil 2025
Modifié(e) : Torsten le 20 Juil 2025
As said: pass the introductory MATLAB course. Otherwise your attempts to use the software will lead to nothing.
a0 = 0.1; a1 = 0.1; c1 = 1; c2 = 0.1; c3 = 0.1; c4 = 0.5; lambda = 4; mu = 1;
x = -6:1/10000:6;
phi = a0 + a1*(c1*cosh(sqrt(lambda^2-4*mu)/2*x)+c2*sinh(sqrt(lambda^2-4*mu)/2*x))./...
(c4*cosh(sqrt(lambda^2-4*mu)/2*x)+c3*sinh(sqrt(lambda^2-4*mu)/2*x));
plot(x,phi)

Connectez-vous pour commenter.

Réponse acceptée

Matt J
Matt J le 20 Juil 2025
Modifié(e) : Matt J le 20 Juil 2025
The following is deliberately not exactly what you asked for, but illustrates one possible approach.
[a0,a1,c1,c2,c3,c4,lambda,mu]=deal(31/100, 19/20, 19/25,7/100,61/100,12/25, 3,17/50 );
x = (-3:0.001:+4)';
z=(sqrt(lambda^2 - 4*mu)/2).*x;
B=[sinh(z), cosh(z)]*[c1, c4;
c2, c3];
y=a0+a1*B(:,1)./B(:,2);
plot(x,y); ylim([-10,10]); xlabel('x'); ylabel('$\varphi(x)$',Interpreter='latex')
  2 commentaires
Tarek
Tarek le 22 Juil 2025
Modifié(e) : Tarek le 22 Juil 2025

Hellow Mr @ Matt J. Thanks for alot.

Does the sequence of constants in the matrix b correct such that the constants C1 multiplied by cosh, C2 sinh, c3 sinh and c4 * cosh ??

Matt J
Matt J le 22 Juil 2025
Modifié(e) : Matt J le 22 Juil 2025
As I said, it's deliberately not exactly what you asked for. I don't promise that the coefficients have been applied as in your original problem.

Connectez-vous pour commenter.

Plus de réponses (1)

Walter Roberson
Walter Roberson le 19 Juil 2025
Modifié(e) : Walter Roberson le 19 Juil 2025
The following is deliberately not exactly what you asked for, but illustrates the techniques you would use.
Q = @(v) sym(v);
a_0 = Q(round(rand,2))
a_0 = 
a_1 = Q(round(rand,2))
a_1 = 
c_1 = Q(round(rand,2))
c_1 = 
c_2 = Q(round(rand,2))
c_2 = 
c_3 = Q(round(rand,2))
c_3 = 
c_4 = Q(round(rand,2))
c_4 = 
lambda = Q(3);
mu = Q(round(rand,2))
mu = 
syms x
num1 = cosh((sqrt(lambda^2 + 3*mu)/2) * x);
num2 = sinh((sqrt(lambda^2 - 2*mu)/2) * x);
den1 = num2;
den2 = num1;
phi(x) = a_0 + a_1 * (c_1 * num1 + c_2 * num2) / (c_3 * den1 + c_4*den2)
phi(x) = 
fplot(phi, [-3 7])
  3 commentaires
Walter Roberson
Walter Roberson le 20 Juil 2025
You appear to be using the MATLAB Connector for Maple -- in other words you have formed a link between MATLAB and Waterloo Maple, to have Maple act as the symbolic engine.
The replacement statement for
phi(x) = a_0 + a_1 * ((c_1 * num1 + c_2 * num2) / (c_3 * den1 + c_4*den2));
is
phi = symfun(a_0 + a_1 * ((c_1 * num1 + c_2 * num2) / (c_3 * den1 + c_4*den2)),x);
I no longer recall whether Maple supports fplot()
Sam Chak
Sam Chak le 20 Juil 2025
If you receive an "Error using maplemex", this indicates that there is an issue with the Maple engine running code from within MATLAB. This article suggests a workaround that you may find helpful: Maple-MATLAB Connector Error.
If you are already familiar with Maple, wouldn't it be easier to plot the graph directly in Maple? This approach eliminates the need to run the Maple code from within MATLAB. Furthermore, why did you not assign these constants directly in your code?
a0 = 0.1;
a1 = 0.1;
c1 = 1;
c2 = 0.1;
c3 = 0.1;
c4 = 0.5;
lambda = 4;
mu = 1;

Connectez-vous pour commenter.

Community Treasure Hunt

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

Start Hunting!

Translated by