Vector to Scalar
Show older comments
Hi there,
I am using this following code to get this weighted average heat capacity value. When I use this value in another file as a divisor there is an "mldivide" error suggesting that this value is either a vector or matrix. Can someone help me as to where am I making the mistake and what. The independent variables like "T0" and "R" have been defined beforehand and have a constant value. Size check of Cpg1 results in... 1 1 ... . Thanks in advance.
% ------ Calculation of Sp. Heat Capacity of Gas Mixture "Cpg" ------
Cp1=(4.568-8.975e-3*T0+3.631e-5*T0^2-3.407e-8*T0^3+1.091e-11*T0^4)*R; % J/mol.K Cp2=(3.259+1.356e-3*T0+1.502e-5*T0^2-2.374e-8*T0^3+1.056e-11*T0^4)*R; % J/mol.K Cp3=(3.912-3.913e-3*T0+1.182e-5*T0^2-1.302e-8*T0^3+0.515e-11*T0^4)*R; % J/mol.K Cp4=(4.395-4.186e-3*T0+1.405e-5*T0^2-1.564e-8*T0^3+0.632e-11*T0^4)*R; % J/mol.K Cp5=(2.883+3.681e-3*T0-0.772e-5*T0^2+0.692e-8*T0^3-0.213e-11*T0^4)*R; % J/mol.K Cp6=(3.539-0.261e-3*T0+0.007e-5*T0^2+0.157e-8*T0^3-0.099e-11*T0^4)*R; % J/mol.K % Cp=[Cp1 Cp2 Cp3 Cp4 Cp5 Cp6]; % Cpg1=sum(y.*Cp); % J/mol.K Cpg1=y1*Cp1+y2*Cp2+y3*Cp3+y4*Cp4+y5*Cp5+y6*Cp6; Cpg=Cpg1/(Mm*1e-3); % J/kg.K % size(Cp1);
2 Comments
Sean de Wolski
on 5 Apr 2011
Can you please reformat your code so it's easily readable. Use the markup help to guide you!
Jan
on 5 Apr 2011
Please post a copy of the error message and mention the line the error occurs in.
Answers (1)
Sean de Wolski
on 5 Apr 2011
doc vectorize
will show you a way to do this automagically.
Categories
Find more on Thermal Analysis 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!