Using a range as an input value in symbolic equations
Show older comments
Hello,
I would like to use a range of value, instead of a specific value, as one of inputs in a symbolic equation, but getting errors, and hope I can get help.
Here is a script I wrote:
syms A omega x positive
% Parameters
alpha = 6*pi;
beta = 25;
omega = 0.1;
A = [0 0.5];
% A = 0.1;
eqn = omega == sqrt((1 + (2*A.*x).^2) ./ ((1-x^2)^2 + (2*A.*x).^2)) ;
X = vpa(solve(eqn,x));
k = beta * alpha^2 / X.^2;
c = 2 .* A .* sqrt(k.*beta)
figure();
fplot(k,A)
hold on
fplot(c,A)
What I am trying to do is:
- solve the equation (eqn) for x and return only positive x (X)
- calculate k and c with a calculated X and given variables
- plot k and c value with respect to A
It returns a correct k and c values when I set A a single value, but when I set this a range of value I get the following error:
Error using .*
Array sizes must match.
When I put A below " X = vpa()" line, it plots right k values, but not c. (it should print around c= 28 when A = 0.1, but gives me around c= 140 in the graph, and now c has a 1x2 system)
I would appreicate your help.
Accepted Answer
More Answers (0)
Categories
Find more on Symbolic Math Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!