필터 지우기
필터 지우기

Solving an equation involving variables as column vector using 'solve' function

조회 수: 5 (최근 30일)
Sanjeet Sawant
Sanjeet Sawant 2020년 12월 8일
답변: Ashish Mishra 2020년 12월 14일
%arrayTest
A=[1;2; 12; 3; 3; 4]
b= [1; 2; 12; 3; 3; 4]
sym tx1
sym tS
x1 = [1:numel(A)]; %row vector
tx1 = transpose(x1) %column vector
S=[1:numel(A)]; %row vector
tS=transpose(S) %column vector
for i = transpose(1:numel(A)) %intializing loop from 1 till the number of rows of A
for j=1 %number of column = 1
tS(i,j) = solve( 1.*b + x1.*A == 0, tx1(i,j)) %solve equation
end
end
%Error
%Check for missing argument or incorrect argument data type in call to function 'solve'.
%Error in TEST_array (line 28)
%tS(i,j) = solve( 1.*b + tx1.*A == 0, tx1(i,j))
Dear Experts!!:)
I am trying to solve an equation containing variables as column vectors. I have declared the symbolic variables and have tried to use the function solve.
I keep getting this error as an incorrect arugument data type for function solve!!
Can someone help me out with this error!??
And also, how can i create and display an array which stores all the solutions of the solve function??
  댓글 수: 2
Walter Roberson
Walter Roberson 2020년 12월 8일
tS(i,j) = solve( 1.*b + x1.*A == 0, tx1(i,j)) %solve equation
tx1 is numeric. Why are you passing it to solve()?
Sanjeet Sawant
Sanjeet Sawant 2020년 12월 8일
tS(i,j) = solve( 1.*b + tx1.*A == 0, tx1(i,j)) %solve equation % missing t of tx1 added
Hi Walter, thank you for the reply!
My idea was to create an unknown variable tx1 having i rows and j columns and solve it using solve().
If that argument doen'nt work, then how can i pass a variable as an array into solve() and find out its value?
Or am i missing any basic concept of solving an equation?:D

댓글을 달려면 로그인하십시오.

답변 (1개)

Ashish Mishra
Ashish Mishra 2020년 12월 14일
Hi Sanjeet
You want to solve the equation for tx1(i,j) but it is a constant array (from 6th line).
Moreover in your equation , everything is constant.
Follow these to documentation.

카테고리

Help CenterFile Exchange에서 Number Theory에 대해 자세히 알아보기

제품


릴리스

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by