Class properties Value not available in a different function.
I have a class called BatteryPlotCalculation and one of its properties is BatteryVoltageSection.
properties
BatteryVoltageSection
end
Then there is a method that sets the values for BatteryVoltageSection.
function plotCalculations(obj)
obj. BatteryVoltageSection %This is the last line of the function and I removed semicolon to see what
% value is coming here and it works
end
Then there is a function to return this value
function Battery_Voltage_Section = getSectionValues(obj)
obj. BatteryVoltageSection % I tried the same here, i.e remove semicolon to see what values are here,
% but here it is empty.
Battery_Voltage_Section = obj.BatteryVoltageSection;
end
So why is it, why is the value available on the top, but not in the second function. They are both the same value. Also in the main program, they are called in the correct order as well.
BatteryPlotValues = BatteryPlotCalculation(app.MeasurementData,app.DataType, app.ReferenceVoltage, app.ReferenceEnergy, MaxMinArray);
BatteryPlotValues.plotCalculations;
BatteryVoltageSection = BatteryPlotValues.getSectionValues;
So this is how they are called in the main program. So you can be sure that second function is only called after the first function has been called, which means the values obtained in the first function for obj.BatteryVoltageSection should be available in the second function as well. But it is not there. Why is that? Thank you.I have a class called BatteryPlotCalculation and one of its properties is BatteryVoltageSection.
properties
BatteryVoltageSection
end
Then there is a method that sets the values for BatteryVoltageSection.
function plotCalculations(obj)
obj. BatteryVoltageSection %This is the last line of the function and I removed semicolon to see what
% value is coming here and it works
end
Then there is a function to return this value
function Battery_Voltage_Section = getSectionValues(obj)
obj. BatteryVoltageSection % I tried the same here, i.e remove semicolon to see what values are here,
% but here it is empty.
Battery_Voltage_Section = obj.BatteryVoltageSection;
end
So why is it, why is the value available on the top, but not in the second function. They are both the same value. Also in the main program, they are called in the correct order as well.
BatteryPlotValues = BatteryPlotCalculation(app.MeasurementData,app.DataType, app.ReferenceVoltage, app.ReferenceEnergy, MaxMinArray);
BatteryPlotValues.plotCalculations;
BatteryVoltageSection = BatteryPlotValues.getSectionValues;
So this is how they are called in the main program. So you can be sure that second function is only called after the first function has been called, which means the values obtained in the first function for obj.BatteryVoltageSection should be available in the second function as well. But it is not there. Why is that? Thank you. I have a class called BatteryPlotCalculation and one of its properties is BatteryVoltageSection.
properties
BatteryVoltageSection
end
Then there is a method that sets the values for BatteryVoltageSection.
function plotCalculations(obj)
obj. BatteryVoltageSection %This is the last line of the function and I removed semicolon to see what
% value is coming here and it works
end
Then there is a function to return this value
function Battery_Voltage_Section = getSectionValues(obj)
obj. BatteryVoltageSection % I tried the same here, i.e remove semicolon to see what values are here,
% but here it is empty.
Battery_Voltage_Section = obj.BatteryVoltageSection;
end
So why is it, why is the value available on the top, but not in the second function. They are both the same value. Also in the main program, they are called in the correct order as well.
BatteryPlotValues = BatteryPlotCalculation(app.MeasurementData,app.DataType, app.ReferenceVoltage, app.ReferenceEnergy, MaxMinArray);
BatteryPlotValues.plotCalculations;
BatteryVoltageSection = BatteryPlotValues.getSectionValues;
So this is how they are called in the main program. So you can be sure that second function is only called after the first function has been called, which means the values obtained in the first function for obj.BatteryVoltageSection should be available in the second function as well. But it is not there. Why is that? Thank you. matlab, oop, function MATLAB Answers — New Questions