How to write properties in vectors in matlab oop?

1 view (last 30 days)
Hi guys,
I want to optimize my model. i have properties like mc,lcc,rc,etc., i need to assign them to a optimisation variable "P" which should be in the form of vector.for example
P(1)=lcc;
P(2)=rc;
P(3)=mc;
i need to assign my properties in this way. Can anyone tell me how write them in a correct way in OOP?
Any suggestions are appreciated.
Thankyou.

Accepted Answer

per isakson
per isakson on 1 Sep 2020
P(1)=obj.lcc;
P(2)=obj.rc;
P(3)=obj.mc;
where obj is the instance variable
  1 Comment
kanuri venkata mohana
kanuri venkata mohana on 1 Sep 2020
Thankyou for your quick reply isakson. if i write this way in properties it is showing an error.
Inputs:
P(1)=mc;
P(2)=lcc;
P(3)=rc;
outputs:
f
classdef Optimization
properties
P=optimvar('P',3)
end
methods(Static)
function f=fit(P)
objCore.mc=P(1);
objCore.lcc=P(2);
.
.
.
f=ObjCore.mc*objCore.lcc;
end
end
end
This is the way my program is. The problem is when i want to assign these optimization variable as input.This program is to show you the syntax of my program. What should i denote in my properties. How to assign the inputs in my function was a problem. I think i explained a bit clear.
Thankyou.

Sign in to comment.

More Answers (0)

Categories

Find more on Programming in Help Center and File Exchange

Tags

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!