Matlab 抽象函数在命令行中工作,而不是作为常量属性在类中工作
下面的函数在命令行中工作,但不是作为常量属性在类中工作。我尝试了很多不同的积分和其他函数的组合,但我无法解决它。 功能Matlab 抽象函数在命令行中工作,而不是作为常量属性在类中工作,matlab,anonymous-function,matlab-class,Matlab,Anonymous Function,Matlab Class,下面的函数在命令行中工作,但不是作为常量属性在类中工作。我尝试了很多不同的积分和其他函数的组合,但我无法解决它。 功能 enthalpyChange = @(constants, temperatureIn, temperatureOut)integral(@(temperature)... F.heatCapacityOfLiquid(constants,temperature), temperatureIn,temperatureOut); 课堂上 cla
enthalpyChange = @(constants, temperatureIn, temperatureOut)integral(@(temperature)...
F.heatCapacityOfLiquid(constants,temperature), temperatureIn,temperatureOut);
课堂上
classdef F
%FORMULAS Summary of this class goes here
% Detailed explanation goes here
properties (Constant)
%F.heatCapacityOfLiquid
t = @(z) z *2
end
properties (Constant)
enthalpyChange = @(constants, temperatureIn, temperatureOut)integral(@(temperature)...
F.heatCapacityOfLiquid(constants,temperature), temperatureIn,temperatureOut);
heatCapacityOfLiquid = @(constants, temperature) constants(1)...
+ temperature * constants(2)...
+ temperature.^2 * constants(3)...
+ temperature.^3 * constants(4);
% heatCapacityOfLiquid = @F.HeatCapacityOfLiquid
end
methods (Static)
function val = HeatCapacityOfLiquid(constants,temperature)
formula = @(constants, temperature) constants(1)...
+ temperature * constants(2)...
+ temperature.^2 * constants(3)...
+ temperature.^3 * constants(4);
val = formula(constants, temperature);
end
end
end
这是不可复制的,在Matlab 2020b上调用
F.焓变化([1 2 3 4],25,60)
这能回答您的问题吗?因此,与前面的类似问题相比,您将一个函数移动为静态
方法,但尝试将其他函数保持为常量属性
。你在上一个问题中已经注意到它不起作用了,你又在问同样的问题。为什么您如此坚持要在属性中执行此计算??顺便说一下,你说的是匿名函数,不是抽象函数。如果你说错话,你会把试图回答你问题的人弄糊涂。请检查大小写。这个问题与方法无关。在我的第一个线程中,我没有在命令行上测试它,如果您有时间检查的话,我也不确定它的语法,但是我想您没有(由于您的大小写错误)。您可以检查并看到它们不是同一个命令。