error in code for research paper

clear all;
clc;
%Hourly variation of climatic parameter and various temperatures (July 13, 2004)
t =[9 10 11 12 1 2 3 4]; %Time is in Hour
I=[366 528 704 660 639 323 167 298]; %intensity is in W\m2
Ta =[31 33 34 36 36 36 35 36]; % ambient temperature at diffrent time
Ti =[34.2 35.1 37.7 38.2 38.7 37.8 37.4 37.7]; %temperature of air at inlet at diffrent time
v = [2.83 3.9 4.3 4.83 4.47 4.8 3.63 3.83]; %velocity of air in duct at diffrent time
%diffrent parameters for calculation
alpha_c= 0.9;
bita_c=0.83;
tau_G=0.95;
tau=0.9;
ita_c= 0.15;
alpha_T= 0.5;
%(alpha*tau)eff= 0.656;
ca=1.005;
ma=0.002;
hc=7.98;
hr=3.47;
Li= 0.05;
Lc= 0.0003;
LT= 0.0005;
LG=0.003;
Lg=0.003;
Ki=0.035;
Kc=0.039;
KT=0.033;
KG=1;
Kg=0.04;
b=0.45;
L=1.2;
for i=1:8
Ti(i)=Ta(i);
ho(i)=5.7+3.8.*v(i);
hi(i)=2.8+3.*v(i);
UT=KT\LT;
Ut(i)=1.\(((LG.\KG)+(1.\(hc+hr))+(Lg.\Kg)+(1.\ho(i))));
Ub(i)=1.\(((Li.\Ki)+1.\hi(i)));
UtT(i)=1.\(((1.\UT)+(1.\Ut(i))));
Ut_air(i)=1.\(((1.\UtT(i))+(1.\hT)));
hT(i)=1.\((LT.\KT)+(1.\hi(i)));
UL=Ut_air(i)+Ub(i);
hp1(i)=(UT.\(Ut(i)+UT));
hp2(i)= (hT(i).\(UtT(i)+hT(i)));
To1(i)= ((((hp1.*hp2.*0.656.*I(i)).\UL)+I(i)).*(1-exp(((-b.*UL).\(ma.*ca)).*L)));
To2(i)=(Ti(i).*exp(((-b.*UL)\(ma.*ca)).*L));
To(i)=To1(i)+To2(i);
Tbs(i)= (((hp1.*0.656.*I(i))+(UtT(i).*Ta)+(hT.*To(i))).\(UtT(i)+hT(i)));
Tc(i)=((([alpha_c.*bita_c+alpha_T(1-bita_c)].*I(i))-(ita_c.*I(i).*bita_c)+(Ut(i).*Ta+UT.*Tbs(i))).\(Ut(i)+UT));
%Average air temperature over the length of air duct below PV module
Tavg(i)= (((hp1.*hp2.*0.656.*I(i).\UL)+I(i)).*(1-((1-exp(-b.*UL.\ma.*ca).*L).\(b.*UL.\ma.*ca))))+Ti(i).*((1-exp(-b.*UL.\ma.*ca).*L).\(b.*UL.\ma.*ca));
end
Ut
Ub
To
Tbs
Tc
Tavg
how to rectify error in code

Antworten (1)

KALYAN ACHARJYA
KALYAN ACHARJYA am 8 Mai 2020
Bearbeitet: KALYAN ACHARJYA am 8 Mai 2020

0 Stimmen

You have not defined/evaluated the ht variables, before to use it.
Ut_air(i)=1.\(((1.\UtT(i))+(1.\hT)));
%...............................^
In the later line, you have assigned hT(i), if it may work, moved the hT before the Ut_air(i) assignment
hT(i)=1.\((LT.\KT)+(1.\hi(i)));
Also note on hT as scalar and hT(i) as vector (same variable)?

15 Kommentare

ALOK DUBEY
ALOK DUBEY am 8 Mai 2020
thanks for reply sir
after following your advice
its showing
Unable to perform assignment because the indices on the left side are not compatible with the size of the right side.
now i corrected code to this but still ..
clear all;
clc;
%Hourly variation of climatic parameter and various temperatures (July 13, 2004)
t =[9 10 11 12 1 2 3 4]; %Time is in Hour
I=[366 528 704 660 639 323 167 298]; %intensity is in W\m2
Ta =[31 33 34 36 36 36 35 36]; % ambient temperature at diffrent time
Ti =[34.2 35.1 37.7 38.2 38.7 37.8 37.4 37.7]; %temperature of air at inlet at diffrent time
v = [2.83 3.9 4.3 4.83 4.47 4.8 3.63 3.83]; %velocity of air in duct at diffrent time
%diffrent parameters for calculation
alpha_c= 0.9;
bita_c=0.83;
tau_G=0.95;
tau=0.9;
ita_c= 0.15;
alpha_T= 0.5;
%(alpha*tau)eff= 0.656;
ca=1.005;
ma=0.002;
hc=7.98;
hr=3.47;
Li= 0.05;
Lc= 0.0003;
LT= 0.0005;
LG=0.003;
Lg=0.003;
Ki=0.035;
Kc=0.039;
KT=0.033;
KG=1;
Kg=0.04;
b=0.45;
L=1.2;
for i=1:8
Ti(i)=Ta(i);
ho(i)=5.7+3.8.*v(i);
hi(i)=2.8+3.*v(i);
UT=KT\LT;
Ut(i)=1.\(((LG.\KG)+(1.\(hc+hr))+(Lg.\Kg)+(1.\ho(i))));
Ub(i)=1.\(((Li.\Ki)+1.\hi(i)));
UtT(i)=1.\(((1.\UT)+(1.\Ut(i))));
hT(i)=1.\((LT.\KT)+(1.\hi(i)));
Ut_air(i)=1.\(((1.\UtT(i))+(1.\hT(i))));
UL=Ut_air(i)+Ub(i);
hp1(i)=(UT.\(Ut(i)+UT));
hp2(i)= (hT(i).\(UtT(i)+hT(i)));
To1(i)= ((((hp1.*hp2.*0.656.*I(i)).\UL)+I(i)).*(1-exp(((-b.*UL).\(ma.*ca)).*L)));
To2(i)=(Ti(i).*exp(((-b.*UL)\(ma.*ca)).*L));
To(i)=To1(i)+To2(i);
Tbs(i)= (((hp1.*0.656.*I(i))+(UtT(i).*Ta)+(hT.*To(i))).\(UtT(i)+hT(i)));
Tc(i)=((([alpha_c.*bita_c+alpha_T(1-bita_c)].*I(i))-(ita_c.*I(i).*bita_c)+(Ut(i).*Ta+UT.*Tbs(i))).\(Ut(i)+UT));
%Average air temperature over the length of air duct below PV module
Tavg(i)= (((hp1.*hp2.*0.656.*I(i).\UL)+I(i)).*(1-((1-exp(-b.*UL.\ma.*ca).*L).\(b.*UL.\ma.*ca))))+Ti(i).*((1-exp(-b.*UL.\ma.*ca).*L).\(b.*UL.\ma.*ca));
end
Ut
Ub
To
Tbs
Tc
Tavg
KALYAN ACHARJYA
KALYAN ACHARJYA am 8 Mai 2020
Bearbeitet: KALYAN ACHARJYA am 8 Mai 2020
Please note that .* use for array multiplication, where as single * scalar multiplication, which may applicable in most part of the code. Also note on "/" Right array division
>> 4\5
ans =
1.2500
>> 4/5
ans =
0.8000
ALOK DUBEY
ALOK DUBEY am 8 Mai 2020
sir, i understand this, but still not getting result, any other way to calculate?
Well, here is the code with the size errors fixed up.
However, I can pretty much guarantee that the code is wrong. The operation A.\B means B divided by A, not A divided by B, and there is no good reason to code such an operation: it just confuses people. The operation A\B is similar to pinv(A)*B and there are good reasons to code it when A and B are non-scalar, but there is no good reason to code the \ operator when A and B are scalar: it just confuses people.
%Hourly variation of climatic parameter and various temperatures (July 13, 2004)
t =[9 10 11 12 1 2 3 4]; %Time is in Hour
I=[366 528 704 660 639 323 167 298]; %intensity is in W\m2
Ta =[31 33 34 36 36 36 35 36]; % ambient temperature at diffrent time
Ti =[34.2 35.1 37.7 38.2 38.7 37.8 37.4 37.7]; %temperature of air at inlet at diffrent time
v = [2.83 3.9 4.3 4.83 4.47 4.8 3.63 3.83]; %velocity of air in duct at diffrent time
%diffrent parameters for calculation
alpha_c= 0.9;
bita_c=0.83;
tau_G=0.95;
tau=0.9;
ita_c= 0.15;
alpha_T= 0.5;
%(alpha*tau)eff= 0.656;
ca=1.005;
ma=0.002;
hc=7.98;
hr=3.47;
Li= 0.05;
Lc= 0.0003;
LT= 0.0005;
LG=0.003;
Lg=0.003;
Ki=0.035;
Kc=0.039;
KT=0.033;
KG=1;
Kg=0.04;
b=0.45;
L=1.2;
N = length(t);
ho = zeros(1,N);
hi = zeros(1,N);
Ut = zeros(1,N);
Ub = zeros(1,N);
UtT = zeros(1,N);
hT = zeros(1,N);
Ut_air = zeros(1,N);
hp1 = zeros(1,N);
hp2 = zeros(1,N);
To1 = zeros(1,N);
To2 = zeros(1,N);
To = zeros(1,N);
Tbs = zeros(1,N);
Tc = zeros(1,N);
Tavg = zeros(1,N);
for i=1:N
Ti(i)=Ta(i);
ho(i)=5.7+3.8.*v(i);
hi(i)=2.8+3.*v(i);
UT=KT\LT;
Ut(i)=1.\(((LG.\KG)+(1.\(hc+hr))+(Lg.\Kg)+(1.\ho(i))));
Ub(i)=1.\(((Li.\Ki)+1.\hi(i)));
UtT(i)=1.\(((1.\UT)+(1.\Ut(i))));
hT(i)=1.\((LT.\KT)+(1.\hi(i)));
Ut_air(i)=1.\(((1.\UtT(i))+(1.\hT(i))));
UL=Ut_air(i)+Ub(i);
hp1(i)=(UT.\(Ut(i)+UT));
hp2(i)= (hT(i).\(UtT(i)+hT(i)));
To1(i)= ((((hp1(i).*hp2(i).*0.656.*I(i)).\UL)+I(i)).*(1-exp(((-b.*UL).\(ma.*ca)).*L)));
To2(i)=(Ti(i).*exp(((-b.*UL)\(ma.*ca)).*L));
To(i)=To1(i)+To2(i);
Tbs(i)= (((hp1(i).*0.656.*I(i))+(UtT(i).*Ta(i))+(hT(i).*To(i))).\(UtT(i)+hT(i)));
Tc(i)=((([alpha_c.*bita_c+alpha_T*(1-bita_c)].*I(i))-(ita_c.*I(i).*bita_c)+(Ut(i).*Ta(i)+UT.*Tbs(i))).\(Ut(i)+UT));
%Average air temperature over the length of air duct below PV module
Tavg(i)= (((hp1(i).*hp2(i).*0.656.*I(i).\UL)+I(i)).*(1-((1-exp(-b.*UL.\ma.*ca).*L).\(b.*UL.\ma.*ca))))+Ti(i).*((1-exp(-b.*UL.\ma.*ca).*L).\(b.*UL.\ma.*ca));
end
disp('UT'); disp(Ut);
disp('Ub'); disp(Ub);
disp('To'); disp(To);
disp('Tbs'); disp(Tbs);
disp('Tc'); disp(Tc);
disp('Tavg'); disp(Tavg);
ALOK DUBEY
ALOK DUBEY am 8 Mai 2020
sir, should i replace .\ to ./ for correcting code?
KALYAN ACHARJYA
KALYAN ACHARJYA am 8 Mai 2020
Bearbeitet: KALYAN ACHARJYA am 8 Mai 2020
"sir, should i replace .\ to ./ for correcting code?"
Understand purpose the use "/" or "\" these both are different. I suggest you to read the Walter's comment again.
If A divided by B, then A/B and "." use for array operation.There are no need dot operation in scalars variables.
Walter Roberson
Walter Roberson am 8 Mai 2020
sir, should i replace .\ to ./ for correcting code?
We do not know; we have not seen the original equations. But we can advise that if the original equations had
then the code for that would not be UT=KT\LT; and would instead be UT=KT./LT;
ALOK DUBEY
ALOK DUBEY am 8 Mai 2020
thanks a lot sir, i understood diffrence you were trying to make me. problem is still i am not able to validate it. i have extracted equations from research paper and trying my level best. its my thesis and research work. i am failing continuously
Walter Roberson
Walter Roberson am 8 Mai 2020
We still have not seen the original equations.
ALOK DUBEY
ALOK DUBEY am 8 Mai 2020
ALOK DUBEY
ALOK DUBEY am 8 Mai 2020
here i am attaching original equations
Walter Roberson
Walter Roberson am 8 Mai 2020
You should not be using any \ or .\ operators in coding that. You should probably be replacing all of the / and ./ operators with ./ operators.
ALOK DUBEY
ALOK DUBEY am 8 Mai 2020
thanks a lot for reply sir. i did procedure you are telling but i am getting values which are out of range.
Sara
Sara am 29 Aug. 2022
Thanks for sharing this type of informative article. I have learned some right stuff here. I really like your articles

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Weather and Atmospheric Science finden Sie in Hilfe-Center und File Exchange

Gefragt:

am 8 Mai 2020

Kommentiert:

am 29 Aug. 2022

Community Treasure Hunt

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

Start Hunting!

Translated by