Variable updates for a brief moment before returning to the original value.
1 ビュー (過去 30 日間)
classdef AircraftClass < ModelClass
properties(SetAccess = private)
P_req % Power Required
P_avail % Power Available
function obj = AircraftClass(B, C, D, E, R, P, T, Z)
% Class constructor
obj.B = B;
obj.C = C;
obj.D = D;
obj.E = E;
obj.R = R;
obj.P = P;
obj.T = T;
obj.Z = Z;
obj.B = B.A;
function [P_avail, P_req, FuelF_req] = calc_point(self, xmsnLimitFlag)
if nargin==1; xmsnLimitFlag=1; end
P_avail = self.get_PowerAvailable(xmsnLimitFlag);
self.P_avail = P_avail;
[P_req, FuelF_req] = self.get_FuelFlow_PowerRequired();
I'm having issues with the "self.P_avail = P_avail" line.
Basically in short, P_avail = self.get_PowerAvailable(xmsnLimitiFlag) updates a list of power data.
However, when I go to assign this new data to self.P_avail, the data updates for a second or two and then reverts back to the old data.
Why is this occuring and how can I make the update permanent?
回答 (3 件)
Steven Lord 2019 年 10 月 8 日
Does the get_PowerAvailable method of this class return a number, an instance of this class, or something else?
When you say "reverts back to the old data" are you looking at the self object inside the calc_point method or are you looking at the object in the workspace that you passed into the calc_point method? If the latter, I'm guessing ModelClass is not a handle class and you don't return the object from the method, so the changes are made only to the copy of the object in the method workspace.
Martin C. 2019 年 10 月 8 日
hmm you might want to use '< handle' if you want to make changes to an object within a method.
Not sure this is your issue.
Could you provide your whole class to better understand what might be going on?