How to write properties in vectors in matlab oop?

2 visualizaciones (últimos 30 días)
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.

Respuesta aceptada

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

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Startup and Shutdown en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by