how can i get the nonzero value of Tdim{i}(1),while i have to start value of k=2:12?
1 view (last 30 days)
Show older comments
here is the result:
Tdim{1}
ans =
0
0.6810
0.7002
0.7326
0.7769
0.8241
0.8472
0.8241
0.7769
0.7326
0.7002
0.6810
here is the main code:
% calculation of Rs
theta=0:30*(pi/180):330*(pi/180);
x=ro*cos(theta);
y=ro*sin(theta);
y1=0;
rs=sqrt((x-e).^2+(y-y1).^2);
D=zeros(1000,12);
for i= 1:1000
for j=1:12
D(i,j)=rs(j)./ri(i);
end
end
D;
Rs=num2cell(D,2);
% Value of angle calculation
Tdimnot=(Thotspot-Tinf)./(Tref-Tinf);
alpha=atan2((y-y1),(x-e))*180/pi;
for k=1:12
if alpha(k)<0
alpha(k)=360+alpha(k);
else
alpha(k)= alpha(k);
end
end
for k=1:12
g(k)=alpha(k)*pi/180;
end
% calculation of 1000 matrix of (12,12)
N=1000;
C=cell(1,N);
for i=1:N
A=zeros(12,12);
for k=1:12
for j=1:12
if j==1
A(k,j)=1./(Rs{i}(k))+Bi(i).*log(Rs{i}(k));
else
A(k,j)=((j-1)*((Rs{i}(k)).^(j-1)+(Rs{i}(k)).^(1-j))./(Rs{i}(k))+Bi(i)*((Rs{i}(k)).^(j-1)-(Rs{i}(k)).^(1-j)))* cos((j-1).*g(k));
end
end
end
C{i}=A;
end
% Calculation of Y
N=1000;
Y=cell(1,N);
E=zeros(12,1);
for i=1:N
E=(C{i})\(B{i});
Y{i}=E;
end
% calculation of each 12 dimensionless temperature at pheripheral
N=1000;
Tdim=cell(1,N);
for i=1:N
F=zeros(12,1);
for k=2:12
F(k,:)=1+(Y{i}(1)).*log(Rs{i}(k))+(Y{i}(k))*((Rs{i}(k)).^(k-1)-(Rs{i}(k)).^(k-1)).*cos((k-1).*g(k));
end
Tdim{i}=F;
Please help me in this ,i am trynig to find for last 4 days.
0 Comments
Answers (1)
Ronit
on 16 Aug 2024
Hello Deepesh,
I understand you are trying to ensure that ‘Tdim{i}(1)’ is nonzero, which can be achieved when its value is derived from the computations involving ’k=2:12’. In your existing code, ’Tdim{i}(1)’ is not explicitly calculated, which results in it being zero. To address this, we can compute ’Tdim{i}(1)’ as a function of the values computed for ’k=2:12’. One straightforward approach is to calculate ’Tdim{i}(1)’ as the average of these values, ensuring it is nonzero and representative of the data. Here's the revised code with this logic incorporated:
% calculation of each 12 dimensionless temperature at peripheral
Tdim = cell(1, N);
for i = 1:N
F = zeros(12, 1);
sum_k_values = 0; % Initialize sum of calculated values for k=2:12
count_k = 0; % Count the number of k values
for k = 2:12
F(k) = 1 + (Y{i}(1)) * log(Rs{i}(k)) + (Y{i}(k)) * ((Rs{i}(k)).^(k - 1) - (Rs{i}(k)).^(k - 1)) * cos((k - 1) * g(k));
sum_k_values = sum_k_values + F(k); % Accumulate the sum
count_k = count_k + 1; % Increment the count
end
% Calculate Tdim{i}(1) as the average of the values from k=2:12
F(1) = sum_k_values / count_k;
Tdim{i} = F;
end
I hope it resolves your query!
0 Comments
See Also
Categories
Find more on Characters and Strings 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!