Hi, im not sure if I'm asking the right question here but I'm having trouble finding an answer on why this happens. In the program bellow, the question lies on the "if". Basically the program gives me a matrix of 301x8x26 of temperatures for a give (Tc, P0, T0). When i do the if im trying to compare and find in the matrix, if there is a value that equals Tc(i) (for the same index) and it gives a matrix full of zeros. However, if i try to print, for example Tc(279)==T22(279,8,26), the answer gives me 1… What im trying to do here is create a matrix with all the values that correspond to one another and then plot P0,T0 and those temperatures as a function of the first 2. If you could help, it would mean a lot. Thank you very much
clcclear allticfile = 'areatemp1';file1 = 'machtemp1';opts = detectImportOptions(file,'NumHeaderLines',0);opts1 = detectImportOptions(file1,'NumHeaderLines',0);T = readtable(file,opts);T.Properties.VariableNames = {'Area','Mach','Temp'};t = readtable(file1,opts1);t.Properties.VariableNames = {'mach','temp'};%condições iniciais do problema
Tc = 20:0.1:50;P0 = 18:25;T0 = 25:50;D0 = input ('What is the size of the hole in microns? ');D0 = D0*10^-6;A0 = ((pi*D0)^2)/4;i = 0;j = 0;k = 0;Patm = 1;R = 8.314;A01 = (1/5)*A0;gama = 1.4;for i = 1:length(Tc); % Cálculo do rho para a temperatura prevista de saida
rhoe(i) = Patm/(R*Tc(i)); for j = 1:length(P0); % Calculo inicial de P01 para dar inicio á interpolação
P011(j) = 0.666*P0(j) + 0.333*Patm; for k = 1:length(T0); mass(j,k) = (0.6856*P011(j)*A01)/(R*T0(k))^(1/2); rho0(j,k) = 0.9805 * (P011(j)/(R*T0(k))); V0(j,k) = mass(j,k)/(rho0(j,k)*A0); P01(j,k) = P0(j)-(1/4)*(rho0(j,k)*V0(j,k)^2); T1(k) = T0(k) * 0.8316; V1(k) = (gama*R*T1(k))^(1/2); P1(k) = P01(j,k) * 0.5274; Areas(i,j,k) = 1/((((R*T0(k))^(1/2))*rhoe(i)*V1(k))/(1.3712*P01(j,k))+sqrt((((R*T0(k))^(1/2)*rhoe(i)*V1(k))/(1.3712*P01(j,k)))^2+(R*T0(k)*rhoe(i)*(P1(k)-Patm))/(0.6856*P01(j,k))^2)); %interpolaton
dif = Areas(i,j,k); %obtained however you want. Can be an array of temperatures
Tarray = table2array(T); tarray = table2array(t); machs(i,j,k) = interp1(Tarray(:,1), Tarray(:,2), dif); temps(i,j,k) = interp1(Tarray(:,1), Tarray(:,3), dif); t1(i,j,k) = temps(i,j,k)*T0(k); temperatura(i,j,k) = interp1(tarray(:,1), tarray(:,2), machs(i,j,k)); T2(i,j,k) = temperatura(i,j,k)*t1(i,j,k); T22(i,j,k) = round(T2(i,j,k),1); end % end
endendif Tc(i) == T22(i,j,k) Tfinal(i,j,k) = 1; else Tfinal(i,j,k) = 0;end% P0 = linspace(18,25,numel(T22));
% T0 = linspace(25,50,numel(T22));
% plot (P0,T22,'b--o',T0,T22,'r--*')
toc
Best Answer