Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,12 @@
function GenericClassInstance = GenericClass(varargin)
if isempty(varargin) %No input arguments
GenericClassInstance.classVariable = 0; %Generates a struct
else
GenericClassInstance.classVariable = varargin{1}; %Generates a struct
end
%Converts the struct to a class of type GenericClass
GenericClassInstance = class(GenericClassInstance,'GenericClass');
end

View file

@ -0,0 +1,4 @@
%Get function
function value = getValue(GenericClassInstance)
value = GenericClassInstance.classVariable;
end

View file

@ -0,0 +1,4 @@
%Set function
function GenericClassInstance = setValue(GenericClassInstance,newValue)
GenericClassInstance.classVariable = newValue;
end

View file

@ -0,0 +1,3 @@
function display(GenericClassInstance)
disp(sprintf('%f',GenericClassInstance.classVariable));
end

View file

@ -0,0 +1,9 @@
>> myClass = GenericClass(3)
3.000000
>> myClass = setValue(myClass,pi)
3.141593
>> getValue(myClass)
ans =
3.141592653589793

View file

@ -0,0 +1,28 @@
classdef GenericClass2
properties
classVariable
end %properties
methods
%Class constructor
function objectInstance = GenericClass2(varargin)
if isempty(varargin) %No input arguments
objectInstance.classVariable = 0;
else
objectInstance.classVariable = varargin{1};
end
end
%Set function
function setValue(GenericClassInstance,newValue)
GenericClassInstance.classVariable = newValue;
%MATLAB magic that changes the object in the scope that called
%this set function.
assignin('caller',inputname(1),GenericClassInstance);
end
end %methods
end

View file

@ -0,0 +1,4 @@
%Get function
function value = getValue(GenericClassInstance)
value = GenericClassInstance.classVariable;
end

View file

@ -0,0 +1,3 @@
function display(GenericClassInstance)
disp(sprintf('%f',GenericClassInstance.classVariable));
end

View file

@ -0,0 +1,8 @@
>> myClass = GenericClass2(3)
3.000000
>> setValue(myClass,pi)
>> getValue(myClass)
ans =
3.141592653589793