Hi everyone,
I got stuck while trying to create a nx1 vector from a nxm matrix.
The matrix is created by two inputs, T01(n,1) and RH(1,m). The result is Td(n,m).
When an element of each row is bigger than an other parameter (Ts2), I have to pick up the value of RH.
I created this code, but it isn't working. (I'm writing here the entire code and I know it's a little bit long)
It returns a vector with all hundrends or zeros .
Could anyone help me please ?
Thank you !
function [c] = cond_humidity1 (T01, RH, c2)n=length(T01); %size of the martixes
m=length(RH);rho=zeros(n,1); % Allocation of some vectors
Ps2=zeros(n,1); Ts2=zeros(n,1);Pv_sat=zeros(n,1);Pv=zeros(n,m);Pv2=zeros(n,m);Td=zeros(n,m);T_wall=zeros(n,1); %This is the vector who's values has to be compared with Td(i,j) values
for i=1:n rho(i) = 28.96/(0.0821*(T01(i) +273.16)); Ps2(i) = 101300 - ((c2^2)/2)*rho(i); Ts2(i) = T01(i)-(c2^2)/2060; T_wall(i) = Ts2(i) + 0.8*(T01(i)-Ts2(i)); Pv_sat(i) = 6.1 *10^((7.4*T01(i))/(T01(i)+240.73)); for j=1:m Pv(i,j) = Pv_sat(i) *(RH(j)/100); Pv2(i,j) = (Ps2(i)/101300)*Pv(i,j); Td(i,j) = 230.73/((7.4/log10(Pv2(i,j)/6.1))-1); %Till here everything works well
if Td(i,j)>=T_wall(i) % and I checked that there exists values
c(i)=RH(j); % Td(i,j) higher than T_wall
end endend end
It returns a vector with all values 100 or 0
Best Answer