How can I set class properties with a vector from another script?
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Leon Stolp
am 30 Mär. 2020
Beantwortet: Peng Li
am 30 Mär. 2020
Hey everybody,
I'm currently trying to set up a Matlab Class for some calculations. I the Class are a lot of functions to calculate the different variables for the maincalculation at the end of the class-script. I set the input values as the class properties. And this is where the problems begin. I want to set these properties with a vector from a different script which is later supposed to run a global optimization. I cannot figure out a way to do that, I've searched a lot in the Community and on Google.
This is what my class-properties currently looks like:
classdef Holtrop
%UNTITLED2 Summary of this class goes here
% Detailed explanation goes here
properties
g = 9.81;
vis = 1.1392e-06;
rho = 1025.8;
Lwl
B
V
T_F
T_A
T
depl
lcb
A_WL
C_Stern
A_BT
S_APP
APP_factor
h_B
A_T
d = -0.9;
end
methods (Static)
end
All the properties without a value are supposed to be set with a vector from a different script.
Any help would be geratly appreciated!
Greetings,
Leon
0 Kommentare
Akzeptierte Antwort
Peng Li
am 30 Mär. 2020
In your class construct you could let it accept input parameters.
e.g.,
methods
function this = Holtrop(varargin)
% for example
Lwl = varargin{1};
end
end
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Environment and Settings finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!