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

1 回表示 (過去 30 日間)
Swati Umamaheshwaran
Swati Umamaheshwaran 2017 年 9 月 15 日
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

採用された回答

Walter Roberson
Walter Roberson 2017 年 9 月 15 日
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)

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCharacters and Strings についてさらに検索

タグ

タグが未入力です。

Community Treasure Hunt

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

Start Hunting!

Translated by