If the buses in your data are numbered consecutively from 1 to nb, where nb is 
the number of buses, then it is simply ...

  gen_lambdas = results.bus(results.gen(:, GEN_BUS), LAM_P);

However, if you have non-consecutive bus numbers, it gets more complicated to 
match up the gens with their buses.

  ng = size(results.gen, 1);
  gen_lambdas = zeros(ng, 1);
  for g = 1:ng
    b = find(results.bus(:, BUS_I) == results.gen(g, GEN_BUS));
    gen_lambdas(g) = results.bus(b, LAM_P);
  end

You can also use the internal (consecutive) bus numbering in order to match the 
generators to the buses. Since the matrices in internal order are also saved in 
results.order.int, the following, which I split out into 3 lines just for 
clarity, should also give you what you want ...

  o  = results.order;                  % re-ordering info
  ig = o.int.gen(o.gen.i2e, GEN_BUS);  % internal bus indices of gens (in orig 
ext order)
  gen_lambdas = o.int.bus(ig, LAM_P);  % lambdas pulled from bus matrix in 
internal order

-- 
Ray Zimmerman
Senior Research Associate
211 Warren Hall, Cornell University, Ithaca, NY 14853
phone: (607) 255-9645



On Jun 23, 2011, at 7:00 AM, Roberto Carvalini wrote:

> Dear Dr. Zimmerman
> 
> I need the Lambda only for generators not for all buses. How can I obtain 
> this? I only found the following command that gives Lamba for all buses
> 
> Results.bus(:,14)
> 
> I need Lambda in a vector only for generators. Is it possible in MATPOWER?
> 
> Best Wishes
> 
> Roberto 
> 
> 
> On Wed, Jun 22, 2011 at 01:26, Roberto Carvalini <[email protected]> wrote:
> Thank you for your help.
> 
> 
> On Tue, Jun 21, 2011 at 19:41, Ray Zimmerman <[email protected]> wrote:
> From Table 4.1 in the manual, if you store the solution in a results struct 
> ...
> 
>   results = runopf('mycase');
> 
> ... the active power generation will be found in ...
> 
>   results.gen(:, PG)
> 
> -- 
> Ray Zimmerman
> Senior Research Associate
> 211 Warren Hall, Cornell University, Ithaca, NY 14853
> phone: (607) 255-9645
> 
> 
> 
> On Jun 21, 2011, at 1:10 PM, Roberto Carvalini wrote:
> 
>> Hi
>> 
>> I want to obtain the active power of generators in runmarket of runopf for 
>> example in case9. How can I obtain it as a vector?
>> 
>> 
>> Best Wishes
>> 
>> Roberto 
> 
> 
> 
> 

Reply via email to