how to replace variable by another variable

5 Ansichten (letzte 30 Tage)
vikas singh
vikas singh am 8 Feb. 2023
Kommentiert: vikas singh am 29 Apr. 2023
Hn=-2*P/(Mu*exp(n^2*pi^2*T/Mu))
I want to replace T by t and want to do calculation
  2 Kommentare
Venkat Siddarth
Venkat Siddarth am 8 Feb. 2023
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 am 10 Feb. 2023
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

Melden Sie sich an, um zu kommentieren.

Antworten (3)

Walter Roberson
Walter Roberson am 8 Feb. 2023
if you are using the symbolic toolbox then subs()
  6 Kommentare
vikas singh
vikas singh am 13 Feb. 2023
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 am 13 Feb. 2023
subs(Hn_new, t, (5:5:1000).')

Melden Sie sich an, um zu kommentieren.


vikas singh
vikas singh am 15 Feb. 2023
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 Kommentare
vikas singh
vikas singh am 25 Apr. 2023
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

Melden Sie sich an, um zu kommentieren.


vikas singh
vikas singh am 25 Apr. 2023
Bearbeitet: Walter Roberson am 25 Apr. 2023
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 Kommentare
Walter Roberson
Walter Roberson am 28 Apr. 2023
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 am 29 Apr. 2023
tell me for both the conditons as well

Melden Sie sich an, um zu kommentieren.

Community Treasure Hunt

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

Start Hunting!

Translated by