Need to assign values to variable in a vector

8 ビュー (過去 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 Center および File ExchangeCalculus についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by