indu15
Junior Member level 3
![Junior Member level 3](/styles/images/ranks/clevel3.gif)
solving equation in matlab
I have 1 equation that has 2 known variables (u, f) and 3 unknown variables (x, y, z).
Each know variables has 6 possible values which are
u = 2.35*10^(-13); 2.504*10^(-11); 3.06*10^(-11); 4.45*10^(-11); 5.46*10^(-11); 5.8*10^(-11)];
f = [1.23*10^4; 1.39*10^4; 1.65*10^4; 1.77*10^4; 1.88*10^4; 1.98*10^4];
Also, I have some idea that x value should be around 6.77*10^(-9), y value should be around 9.3*10^(-20), z value should be around 4.0.
I wrote the following code:
clc; clear; close all;
syms x y z
%range of x, y, z
x = linspace(10^(-9), 10*10^(-9));
y = linspace(10^(-20), 10*10^(-20));
z = linspace(1, 10);
%sqrt(F)= f:
%finding Uo = x, delta(E) = y, Er = z:
% assign 6 values for u and 6 values for v
u = [2.35*10^(-13); 2.504*10^(-11); 3.06*10^(-11); 4.45*10^(-11); 5.46*10^(-11); 5.8*10^(-11)];
f = [1.23*10^4; 1.39*10^4; 1.65*10^4; 1.77*10^4; 1.88*10^4; 1.98*10^4];
a=(1.6*10^(-19))^3/(pi*8.85*10^(-12));
b=1164.3*1.38*10^(-23);
% Define equation and unknown variables
eq1 = 'u=x*exp(-((-y-sqrt(a/z))*f)/b)';
vars = 'x, y, z';
S = solve(eq1,vars)
I am getting following result.
Warning: 1 equations in 3 variables. New variables might be introduced.
> In solve>mupadSolve at 203
In solve at 93
In test5 at 24
S =
x: [1x1 sym]
y: [1x1 sym]
z: [1x1 sym]
>> S.x
ans =
u/exp((f*(z2 + (a/z1)^(1/2)))/b)
>> S.y
ans =
z2
>> S.z
ans =
z1
Can anyone please advise me how to get the values for x, y, z.
Thank you
I have 1 equation that has 2 known variables (u, f) and 3 unknown variables (x, y, z).
Each know variables has 6 possible values which are
u = 2.35*10^(-13); 2.504*10^(-11); 3.06*10^(-11); 4.45*10^(-11); 5.46*10^(-11); 5.8*10^(-11)];
f = [1.23*10^4; 1.39*10^4; 1.65*10^4; 1.77*10^4; 1.88*10^4; 1.98*10^4];
Also, I have some idea that x value should be around 6.77*10^(-9), y value should be around 9.3*10^(-20), z value should be around 4.0.
I wrote the following code:
clc; clear; close all;
syms x y z
%range of x, y, z
x = linspace(10^(-9), 10*10^(-9));
y = linspace(10^(-20), 10*10^(-20));
z = linspace(1, 10);
%sqrt(F)= f:
%finding Uo = x, delta(E) = y, Er = z:
% assign 6 values for u and 6 values for v
u = [2.35*10^(-13); 2.504*10^(-11); 3.06*10^(-11); 4.45*10^(-11); 5.46*10^(-11); 5.8*10^(-11)];
f = [1.23*10^4; 1.39*10^4; 1.65*10^4; 1.77*10^4; 1.88*10^4; 1.98*10^4];
a=(1.6*10^(-19))^3/(pi*8.85*10^(-12));
b=1164.3*1.38*10^(-23);
% Define equation and unknown variables
eq1 = 'u=x*exp(-((-y-sqrt(a/z))*f)/b)';
vars = 'x, y, z';
S = solve(eq1,vars)
I am getting following result.
Warning: 1 equations in 3 variables. New variables might be introduced.
> In solve>mupadSolve at 203
In solve at 93
In test5 at 24
S =
x: [1x1 sym]
y: [1x1 sym]
z: [1x1 sym]
>> S.x
ans =
u/exp((f*(z2 + (a/z1)^(1/2)))/b)
>> S.y
ans =
z2
>> S.z
ans =
z1
Can anyone please advise me how to get the values for x, y, z.
Thank you