How to substitute x and y with X and Y respectively and get the same result as Test1(last line of my code)
2 views (last 30 days)
Show older comments
Below is my code. About the last line of my code, I would like to know how to substitute x and y with X and Y respectively and get the same result as Test1. Test1 is the output of "combine_wxx=vpa(combine_wxx)"
Thank you very much!!
clc
clear
format long
E=209e+3;
q=-1;
h=15;
D=6.459478021978022e+07;
I=2.8125e+02;
a=600;b=2400;
% change the value of mn
n =3;
[T1, T2] = meshgrid(1:2:n);
mn = [T1(:), T2(:)]
syms x y
x_value=0:100:600;
y_value=0:100:2400;
[X,Y]=meshgrid(x_value,y_value) ;
% Fine the amn
len=length(mn);
amn=zeros(1,len);
for i=1:len
m=mn(i,1);
n=mn(i,2);
amn(i)=(16*q/(m*n*D*pi^6))*(1/((m/a)^2+(n/b)^2)^2);
end
% Fine the wmn
for i=1:len
m=mn(i,1);
n=mn(i,2);
wmn(i)=amn(i).*((sin(m.*pi.*x./a)).*(sin(n.*pi.*y./b)));
wxx(i)=diff(wmn(i),x,2);
wyy(i)=diff(wmn(i),y,2);
end
combine_wxx=sum(wxx);
combine_wxx=vpa(combine_wxx)
% Test1 is the output of "combine_wxx=vpa(combine_wxx)" and I substitute x and y with X and Y respectively.
Test1=0.000010011120098275262104647981847237*sin(0.015707963267948966192313216916398.*X).*sin(0.0039269908169872415480783042290994.*Y) + 0.000033438807664284280352743957795044*sin(0.015707963267948966192313216916398.*X).*sin(0.0013089969389957471826927680763665.*Y) + 0.00012498683220294698455252916478176.*sin(0.0039269908169872415480783042290994.*Y).*sin(0.0052359877559829887307710723054658.*X) + 0.00081090072796029611652649055794769.*sin(0.0052359877559829887307710723054658.*X).*sin(0.0013089969389957471826927680763665.*Y)
% How should I use "subs" function or other function which you suggest to substitute x and y with X and Y respectively and get the same result as Test1
% I have tried "wxx_value=subs(combine_wxx,[x,y],[X,Y])" but it showed "Inconsistency between sizes of second and third arguments."
0 Comments
Answers (1)
Sambit Supriya Dash
on 8 Jun 2021
Just before your major calculations (where you are willing to use the variables X & Y), you can add a line,
x = X; y = Y;
Then, whatever you write in terms of further calculations, you can use x & y as the replaced variables of X & Y.
See Also
Categories
Find more on Resizing and Reshaping Matrices 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!