How do i use an unknown from an unsolved identity in my equations?

2 visualizzazioni (ultimi 30 giorni)
Hello, I'm a newbie to MATLAB and am having a problem with something which I believe should be quite simple.
I have a comlicated identity, the unknown of which I need in another equation. The code below shows a simplified version of what I'm trying to do.
clear all
clc
syms m
solve('m+6=4-m', m)
x=[0:1:10];
for i=1:11
y(i)=m*x(i)+5;
end
hold on
plot (x, y)
It's easy to see here that m = -1, and if I replace lines 3 and 4 with "m=-1;", I get my graph. However my identity is much more complicated than that shown and I can't rearrange it as "m=...". Can anyone help? I hope this was clear, please let me know if more information is needed.
These are the error messages I'm getting:
Error using sym/solve>getEqns (line 418)
List of equations must not be empty.
Error in sym/solve (line 226)
[eqns,vars,options] = getEqns(varargin{:});
Error in Test (line 4)
solve('m+6=4-m', m)

Risposta accettata

Ameer Hamza
Ameer Hamza il 25 Set 2020
There are some syntax issues in your code. Check the following code
clear all
clc
syms m
m_ = solve(m+6==4-m, m);
x= 0:1:10;
y = zeros(size(x)); % pre-allocation
for i=1:11
y(i)=m_*x(i)+5;
end
hold on
plot (x, y)
  4 Commenti

Accedi per commentare.

Più risposte (0)

Prodotti


Release

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by