Keep getting and error and I don't know why

12 views (last 30 days)
So while coding i keep getting this error "Unable to perform assignment because the left and right sides
have a different number of elements." i dont understand why i am getting it. can anyone explain to me why.
close all
clear all
clc
P_h=101325;
T_hin=500;
UA=130;
T_cin=300;
P_c=80*101325;
m_doth=0.08;
m_dotc=0.02;
data_co2=xlsread('CO_2 Thermal Properties');
T_co2=transpose(data_co2(:,1));
cp_co2=transpose(data_co2(:,9))*10^3;
mu_co2=transpose(data_co2(:,12));
data_O2=xlsread('O2 Thermal Properties');
data_N2=xlsread('N2 Thermal Properties');
T_n2=transpose(data_N2(:,1));
cp_n2=transpose(data_N2(:,9))*10^3;
mu_n2=transpose(data_N2(:,12));
T_o2=transpose(data_O2(:,1));
cp_o2=transpose(data_O2(:,9))*10^3;
mu_o2=transpose(data_O2(:,12));
i_o2=transpose(data_O2(:,6));
i_n2=transpose(data_N2(:,6));
i_co2=transpose(data_co2(:,6));
T_air=T_o2;
cp_air=cp_o2.*0.2+cp_n2.*0.8;
i_air=i_o2.*0.2+i_n2.*0.;
N=50;
delx=(1/(N-1));
for i=1:N
x_bar(i)=(i-1)*delx;
end
T_cout=450;
T_c(1)=T_cout;
T_h(1)=T_hin;
% error = 0.1;
% T_c(N)=T_cin;
% if error > abs(T_c(N)-T_cin)
% T_cout=T_cout-0.1;
for i=1:N-1
clear z j
z=find(round(T_c(i),1) == T_co2);
j=find(round(T_h(i),1) == T_air);
C_dotc(i)=(cp_co2(z)).*m_dotc;
C_doth(i)=(cp_air(j)).*m_doth;
T_c(i+1)=T_c(i)-UA*(T_h(i)-T_c(i))*delx/C_dotc(i);
T_h(i+1)=T_h(i)-UA*(T_h(i)-T_c(i))*delx/C_doth(i);
end
figure(1)
plot(T_co2,cp_co2,T_air,cp_air)
xlabel('Temp [K]')
ylabel('cp')
title('Temp vs cp')
figure(2)
plot(x_bar,T_c, x_bar,T_h)
xlabel('dimensionless postion')
ylabel('Temp [K]')
title('dimensionless position vs Temp')

Accepted Answer

Dylan Bull
Dylan Bull on 24 Apr 2022
Edited: Dylan Bull on 24 Apr 2022
It has to do with me not putting the values above or below the values which are returned. it was a hard thing to find when it doesnt work the way you want it to

More Answers (1)

Image Analyst
Image Analyst on 21 Apr 2022
You forgot to attach your workbooks so we can't run your code.
Usually (always) this error means that you're trying to stuff a whole multi-element array into a single element of another array.
Like you can't do this
v = [1,2,3,4]; % A 4-element array.
% Try to reassign the value of the first element.
v(1) = rand(100, 1); % Trying to put 100 elements into a space designed for only 1 scalar.
Unable to perform assignment because the left and right sides have a different number of elements.
  3 Comments

Sign in to comment.

Categories

Find more on MATLAB 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!