Effacer les filtres
Effacer les filtres

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

2 vues (au cours des 30 derniers jours)
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

Réponse acceptée

Walter Roberson
Walter Roberson le 15 Sep 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)

Plus de réponses (0)

Catégories

En savoir plus sur Characters and Strings dans Help Center et File Exchange

Tags

Aucun tag saisi pour le moment.

Community Treasure Hunt

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

Start Hunting!

Translated by