how to replace variable by another variable

12 次查看(过去 30 天)
Hn=-2*P/(Mu*exp(n^2*pi^2*T/Mu))
I want to replace T by t and want to do calculation
  2 个评论
Venkat Siddarth
Venkat Siddarth 2023-2-8
Can you elaborate the query,on whats the result you are getting when you replace "T" with "t" in the equation itself i.e
Hn=-2*P/(Mu*exp(n^2*pi^2*t/Mu))?
vikas singh
vikas singh 2023-2-10
actually I have to replace T by t/L and again i have to give different value to t for calculation. and some for loop is also involve in the equation for n

请先登录,再进行评论。

回答(3 个)

Walter Roberson
Walter Roberson 2023-2-8
if you are using the symbolic toolbox then subs()
  6 个评论
vikas singh
vikas singh 2023-2-13
can you please tell me if I want to give value of t as 5, 10, 15, 20,25,.......,1000 then how to give here in the code. thanks in advance.

请先登录,再进行评论。


vikas singh
vikas singh 2023-2-15
when I'm using the following code to evaluate z value . I'm getting the Q value and all the value after Q is zero. I m not getting where I'm wrong.
clc;
clear all;
close all;
l=10000;
x=0:100:l;
t=[0;1;5;10;15;20;25];
H=30;
Mu=2.8e-1;
D=31;
k=0.01132;
k1=l/H;
for n=1:100
a=2*H;
b=(1-(-1)^n*exp(-k*l))/((n*pi+(k^2*l^2)/(n*pi)));
c=1/(n*pi);
Cn(n)=a*(b-c);
end
s=0;
for n=1:100
d= sin(n*pi*x/l);
q= exp((-n^2*pi^2*t)/(Mu^2*l));
aa=Cn(n).*d.*q;
s=s+aa;
end
syms X T
for n=1:100
H0=@(X,T)Cn(n).*sin(n*pi*X).*exp(-n^2*pi^2*T/Mu)+H*X/(D-H)+H/(D-H);
y=diff(H0*diff(H0,X),X);
Q=int(y*sin(n*pi*X),X,0,1);
P=int(Q*exp(n^2*pi^2*T/Mu),T,0,T);
Hn=-2*P/(Mu*exp(n^2*pi^2*T/Mu));
H1=Hn.*sin(n*pi*X);
for i=1:size(t,1)
for j=1:length(x)
H=(subs(H1,{X,T},{x(j)/l,t(i,1)/(Mu*l)}));
ZZ(j,1)=double(H);
end
XX(i,1)=sum(ZZ);
clear ZZ
end
s1=((D-H)^2).*XX/l;
end
j=(H*x)/l;
z=s-j-s1
plot(x,z)
  4 个评论
vikas singh
vikas singh 2023-4-25
I want to multiply r and f value in the following code. how to do it.
clc;
clear all;
close all;
L=600;
T=365;
delt=0.025;
k=8.64;
aa=delt*k*(1+delt);
epc=0.3;
H=50;
mu=epc/(k*delt*H);
w1=86400*1*10^-8;
w2=8*86400*10^-8;
dx=1;
dt=1;
d=(mu*dt)/(dx^2);
N=L/dx +1;
M=T/dt +1;
for i=1:N
x(i)=0+(i-1)*dx;
end
for n=1:M
t(n)=0+(n-1)*dt;
end
for n=1:M
for i=1:N
if x(i)>=250 && x(i)<=350
r(i)=w2;
else
r(i)=w1;
end
end
if t(n)<=182.5
f(n)=sin(2*pi*t(n)/365).^2;
else
f(n)=0;
end
end

请先登录,再进行评论。


vikas singh
vikas singh 2023-4-25
编辑:Walter Roberson 2023-4-25
I'm writing the following but it is giving me zero and showing matrix dimension is not agree
clc;
clear all;
close all;
L=600;
T=365;
delt=0.025;
k=8.64;
aa=delt*k*(1+delt);
epc=0.3;
H=50;
mu=epc/(k*delt*H);
w1=86400*1*10^-8;
w2=8*86400*10^-8;
dx=1;
dt=1;
d=(mu*dt)/(dx^2);
N=L/dx +1;
M=T/dt +1;
for i=1:N
x(i)=0+(i-1)*dx;
end
for n=1:M
t(n)=0+(n-1)*dt;
end
for n=1:M
for i=1:N
if x(i)>=250 && x(i)<=350
r(i)=w2;
else
r(i)=w1;
end
end
if t(n)<=182.5
f(n)=sin(2*pi*t(n)/365).^2;
else
f(n)=0;
end
f2=r.*f
end
f2 = 1×601
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Arrays have incompatible sizes for this operation.
  5 个评论
Walter Roberson
Walter Roberson 2023-4-28
I want to plot between x and -(z(n+1,i)).^0.5
Do you mean that you have an independent variable 1:N on the x axis, and you want to treat the variable x and that particular expression as dependent variables to be drawn and you want to fill the area between the two lines?
Or is your x variable to be treated as the x axis and you want to draw -(z(n+1,i)).^0.5 even though that appears to be independent of x?

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Mathematics 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by