How to write properties in vectors in matlab oop?

1 Ansicht (letzte 30 Tage)
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.

Akzeptierte Antwort

per isakson
per isakson am 1 Sep. 2020
P(1)=obj.lcc;
P(2)=obj.rc;
P(3)=obj.mc;
where obj is the instance variable
  1 Kommentar
kanuri venkata mohana
kanuri venkata mohana am 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.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Programming finden Sie in Help Center und File Exchange

Tags

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by