0

Following function works at the command line, however not in the class as a constant property. I tried a lot of different combination with integral other function etc. but I was unable to solve it. Function

         enthalpyChange =  @(constants, temperatureIn, temperatureOut)integral(@(temperature)...
       F.heatCapacityOfLiquid(constants,temperature), temperatureIn,temperatureOut);

In Class

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
RedGermen
  • 13
  • 3
  • 1
    This is not reproducible, it appears to work fine on Matlab 2020b calling `F.enthalpyChange([1 2 3 4],25,60)` – Daniel Aldrich Nov 05 '20 at 15:27
  • Does this answer your question? [Weird error while using constant properties in class](https://stackoverflow.com/questions/64667602/weird-error-while-using-constant-properties-in-class) – Hoki Nov 06 '20 at 10:07
  • So compared to your previous similar question, you moved one function as a `static` method but try to keep the others as `constant property`. You already noticed it doesn't work in your last question, you are asking the same thing again. Why do you insist so much on having this calculations performed in a `property` ?? By the way, you are talking about _anonymous_ functions, not _abstract_. You'll confuse people trying to answer your question if you state it wrong. – Hoki Nov 06 '20 at 10:11
  • Check the upper, lower case. This question is irreverent with methods. In my first thread, I didn't test it on the command line and wasn't sure with the syntax, if you have time to check, but I suppose you don't (due to your upper, lower case mistake). You can check and see they are not the same command. – RedGermen Nov 06 '20 at 16:30

0 Answers0