How to write properties in vectors in matlab oop?

1 visualizzazione (ultimi 30 giorni)
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.

Risposta accettata

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

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Programming in Help Center e File Exchange

Tag

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by