Borrar filtros
Borrar filtros

solve n equation with n Variable

19 visualizaciones (últimos 30 días)
Milad Javan
Milad Javan el 7 de Nov. de 2011
Respondida: Yagna V el 22 de En. de 2020
I want to write a program that get n from user and solve n equation with n variable. How should I write solve command.
variable: syms V1 , V2 , ... , Vn
equations: eq=[eq1 eq2 ... eqn]
solve(eq(1:end),V1,V2,...,Vn)
My question is about writing n variable at solve command. Thanks.

Respuesta aceptada

Andrei Bobrov
Andrei Bobrov el 7 de Nov. de 2011
variant
function out = slveqs(namvar,n,eqs)
%{
namvar - string (e.g. namvar = 'V')
n - double (e.g. n = 2)
eqs - cell array string value(e.g. eqs = {'V1^2-V2 = 4','V1+V2 = 8'})
%}
k = num2cell(sym(namvar,[n,1]));
out = solve(eqs{:},k{:});
  1 comentario
armood
armood el 14 de Jun. de 2019
Hello
I appericiate your attention. I tried this script but I'm affraid it doesn't work propperly. Can you help me out please? an example or something...

Iniciar sesión para comentar.

Más respuestas (1)

Yagna V
Yagna V el 22 de En. de 2020
clc;
clear all;
n=input("Enter Number of Equations to be formed: ");
syms v [1,n]
for i=1:n
eqn(i) = (v(i)+1)^2+(v(i)-1)^2==20;
disp(eqn(i));
end
S=solve(eqn)
After this u get an array where the values are stored in symbols

Categorías

Más información sobre Symbolic Math Toolbox en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by