Creating user defined variables and solving systems with a script
이전 댓글 표시
Hi all, been a while since I needed a question answered, so here goes:
I am creating a script that is used to solve a system of equations defined by a user. The general form of the equation to be solved is K*u=P, where u and P are both column vectors that contain variables, and K is a square matrix the size of the number of rows in u and P. An example would be:
[1,1,1,1;1,1,1,1;1,1,1,1;1,1,1,1][2,u2,u3,2]=[P1,1000,2000,P4]
Where K is generated via user input, and the user is to define all values of u and P. My problem is that I don't know how to have matlab accept variables as a user input, and I don't know how I would solve such a system of equations using Matlab.
Thanks,
--Alex--
답변 (1개)
Youssef Khmou
2013년 11월 17일
Use input:
K=input(' Enter matrix :\n');
% You enter the K(i,j) as :[4 5 8 7;2 3 6 5] then K is the entered matrix
댓글 수: 6
Walter Roberson
2013년 11월 17일
input('Enter Variable Name', 's')
Alex
2013년 11월 17일
Walter Roberson
2013년 11월 17일
편집: Walter Roberson
2013년 11월 17일
When the inputs to u or P contain variables, are the variables intended to represent variables that have already been given a value, or are the variables intended to represent symbols with the output expected to be in the form of symbols ?
Do you have access to the Symbolic Toolbox ?
Alex
2013년 11월 17일
Walter Roberson
2013년 11월 17일
Do you have access to the Symbolic Toolbox ?
Alex
2013년 11월 17일
카테고리
도움말 센터 및 File Exchange에서 Symbolic Math Toolbox에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!