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

5 次查看(过去 30 天)
  3 个评论
Torsten
Torsten 2025-7-19
编辑:Torsten 2025-7-19
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 2025-7-20
编辑:Torsten 2025-7-20
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)

请先登录,再进行评论。

采纳的回答

Matt J
Matt J 2025-7-20
编辑:Matt J 2025-7-20
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 个评论
Tarek
Tarek 2025-7-22
编辑:Tarek 2025-7-22

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 2025-7-22
编辑:Matt J 2025-7-22
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.

请先登录,再进行评论。

更多回答(1 个)

Walter Roberson
Walter Roberson 2025-7-19
编辑:Walter Roberson 2025-7-19
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 个评论
Walter Roberson
Walter Roberson 2025-7-20
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 2025-7-20
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;

请先登录,再进行评论。

Community Treasure Hunt

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

Start Hunting!

Translated by