How to solve the below numerical
1 view (last 30 days)
Show older comments
How to solve the below equation for x and plot the values of x with respect to y and z where y varies from 100 - 500 and z varies from 200-600.
H = x*exp((3*x*y/sin(x))* z) + cos(2*x*z/y) + exp(-0.5*x);
%%I tried the below
syms x;
z = poles(H, x, 0, 3);
%%Not working for me
0 Comments
Accepted Answer
John D'Errico
on 26 Feb 2022
So for any given value of H, y, znd z, you want to be able to write x as a function of them, then drawing a nice pretty picture.
It is trivially easy to write an expression that has no analytical solution. This is probably one of them, with x falling both inside and outside the exponentials, as well as a trig function. Worse, it may almost certainly be the case where there are mutliple solutions. Trig functions always create those situations.
Finally, you will have the problem that if such a relationship did exist, it would be a function of THREE variables, H,y,z. Unless perhaps you mean that H is supposed to be zero. But if H is some general parameter, then the plot you would generate would be a 4-dimensional plot, difficult to view on your monitor.
If you want to plot the solutions with H=0, this will do it:
H = @(x,y,z) x.*exp((3*x.*y./sin(x)).*z) + cos(2*x.*z./y) + exp(-0.5*x);
fimplicit3(H)
Note the complexity of the result, which suggests that no simple solution will exist. The above is merely a plot. There is no analytical form produced to generate that result.
4 Comments
John D'Errico
on 26 Feb 2022
Edited: John D'Errico
on 26 Feb 2022
Consider what happens when x and y are vectors or matrices.
x = 1:5;
y = [2 3 5 7 11];
Suppose we just wanted to multiply the elements in each and find the product? See that
x.*y
succeeds, but x*y fails.
x*y
The difference is that the * operator is used in MATLAB to perform a DOT product, used in linear algebra.
As I wrote it, had I not used the dotted operators in that expression, while fimplicit3 would not have overtly failed, it would have issued warning messages.
Note that you do NOT need to use a dotted operator to multiply a scalar with a vector or matrix. MATLAB understands how to multiply 2*x.
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!