Need to assign values to variable in a vector

조회 수: 3 (최근 30일)
Altaf Adam Rawoot
Altaf Adam Rawoot 2019년 11월 8일
답변: Ajay Pattassery 2019년 11월 11일
x1=-1, y1=1, x2=-1, y2=-1, x3=1, y3=-1, x4=1, y4=1
A=[1 x1 y1 x1*y1;1 x2 y2 x2*y2;1 x3 y3 x3*y3;1 x4 y4 x4*y4]
syms x y
D=[1 x y x*y]
[K]=D*inv(A);
N1=K(1,1)
N2=K(1,2)
N3=K(1,3)
N4=K(1,4)
[G]=[diff(N1,x) diff(N2,x) diff(N3,x) diff(N4,x);diff(N1,y) diff(N2,y) diff(N3,y) diff(N4,y)]
%until here i got the value of [G] in terms of x and y. Now i need to get the value from user for x and y and substitue it in the matrix to get the out put matrix.
function [G] = untitled(x,y);
x=input("Please Input X Co-Ordinate");
y=input("Please Input Y Co-Ordinate");
end

답변 (1개)

Ajay Pattassery
Ajay Pattassery 2019년 11월 11일
The subs function helps in doing the symbolic substitution. The following snippet will do the substitution.
x1=input("Please Input X Co-Ordinate");
y1=input("Please Input Y Co-Ordinate");
G = subs(G,[x,y],[x1 y1])

카테고리

Help CenterFile Exchange에서 Symbolic Math Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by