Borrar filtros
Borrar filtros

how to accept equations from the user and convert to a matrix?

2 visualizaciones (últimos 30 días)
Please help me. I am writing a code to accept equations from the user and then convert it to a matrix to perform row operations. The purpose is to create a generic code for a system of linear equations. Following is the code .
m = input ('Enter number of unknowns: ');
n = input ('Enter number of equations: ');
syms x y
for j=1:n
equ(j)= input ('Enter equations: ','s');
end
for j=1:n
func(j) = evalin(symengine, equ(j));
end
for j=1:n
[A,B] = equationsToMatrix([func(j)], [x, y])
end

Respuesta aceptada

Walter Roberson
Walter Roberson el 15 de Sept. de 2017
Change
equ(j)= input ('Enter equations: ','s');
to
equ(j) = string( input ('Enter equations: ','s') );
This requires R2016b or later.
This change is adjusting for the fact that in MATLAB, input() with the 's' parameter requires a character vector, which will be a vector, and vectors cannot be stored into a single location like equ(j) . The string() call converts the character vector into a string object, and string objects can be stored into a single location like equ(j)

Más respuestas (0)

Categorías

Más información sobre Characters and Strings en Help Center y File Exchange.

Etiquetas

Aún no se han introducido etiquetas.

Community Treasure Hunt

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

Start Hunting!

Translated by