Using imported data in an equation

1 次查看(过去 30 天)
I have an equation with several known constants and three variables; efficiency, Cp and T1. I am trying to calculate efficiency. I have attached an image of the equation.
However, Cp changes depending on T1. I have imported an excel spreasheet that gives the values of Cp at a variety of temperatures.
How do I use MATLAB to calculate efficiency at the specified combinations of T1 and Cp so that I can plot a graph of T1 against efficiency?

采纳的回答

Cris LaPierre
Cris LaPierre 2021-3-15
编辑:Cris LaPierre 2021-3-15
I would create a vector of T1 values, and a vector of the corresponding cp values. I would then compute efficiency using the vectors of T1 and cp. If the equation is set up properly using array (elementwise) operations, efficiency should be a vector the same size as T1.
From there, you can use the plot command.
See Ch 6 of MATLAB Onramp for more on array calculations.
  2 个评论
Tom Morris
Tom Morris 2021-3-15
When I set the two variables as arrays, both (29x1 double), my resulting efficiency value is a (29x29) .
This is the equation
Eff1=1-((((cp.*T.*(Vr.^(R./cp))+(((((2.*l.*S1)./n)-((S1+Ve)./(pi.*rb.^2))).^2)/((cp.*T)+((S1.*Ve)./(sqrt(2).*n.*pi.*rb.^2)).^2))))))
All the variables apart from T, cp and Eff1 are constants.
Any idea where I'm going wrong.
Cris LaPierre
Cris LaPierre 2021-3-15
Sounds like a result of implicit expansion. Somewhere you are multiplying or adding a 1x29 with a 29x1, resulting in a 29x29.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Mathematics 的更多信息

产品


版本

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by