How to write properties in vectors in matlab oop?

1 次查看(过去 30 天)
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.

采纳的回答

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

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Programming 的更多信息

标签

产品

Community Treasure Hunt

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

Start Hunting!

Translated by