how to replace variable by another variable

조회 수: 14 (최근 30일)
vikas singh
vikas singh 2023년 2월 8일
댓글: vikas singh 2023년 4월 29일
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.
Walter Roberson
Walter Roberson 2023년 2월 13일
subs(Hn_new, t, (5:5:1000).')

댓글을 달려면 로그인하십시오.


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?
vikas singh
vikas singh 2023년 4월 29일
tell me for both the conditons as well

댓글을 달려면 로그인하십시오.

카테고리

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