Need to assign values to variable in a vector

3 views (last 30 days)
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

Answers (1)

Ajay Pattassery
Ajay Pattassery on 11 Nov 2019
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])

Categories

Find more on Symbolic Math Toolbox in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!