Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8097943
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T21:55:11+00:00 2026-06-05T21:55:11+00:00

Hi I have the following code for j = 1:2, for i = 1:24,

  • 0

Hi I have the following code

for j = 1:2,

    for i = 1:24,

        for K = 1:3,

            for M = 1:3,
                PV_output(:,:,K) = real(PV_power_output(:,:,K));
                WT_output(:,:,M) =  WT_power_output(:,:,M);
                PVenergy = sum(sum(PV_output(:,:,1)));
                WTenergy = sum(sum(WT_power_output(:,:,1)));
                f = [((CRF*CC_PV)/PVenergy)+OM_PV; ((CRF*CC_WT)/WTenergy)+OM_WT];
                A = [-PV_output(j,i,K) -WT_output(j,i,M)];
                b = -Demand(j,i);
                lb = zeros(2,1);
                ub = [max_PV_area/PV_area max_WT_area/WT_area]';
            end
        end
    end
end

PV_output and WT_output are 365 x 24 matrices with three different sets of matrices that I am trying to examine individually..Demand is a 365 x 24 matrix.

When I run linprog it seems that it is only reading the last element of the above matrices and also when I check the size of A and b I get a 1×2 and 1×1 whereas I should be getting a 365x24x3 and 365×24

Any help?!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T21:55:12+00:00Added an answer on June 5, 2026 at 9:55 pm

    When you do this

        A = [-PV_output(j,i,K) -WT_output(j,i,M)];
    

    you are assigning A to be a 1 x 2 array at every iteration. The variable returned by -PV_output(j,i,K) and -WT_output(j,i,M) are scalars, so you should not expect A to be anything other an 1 x 2 in size.

    Similarly

        b = -Demand(j,i);
    

    simply returns a scalar element of the Demand matrix and so b has size 1 x 1.

    It would appear that you wish to use these values as elements in a much larger matrix so you should assign them to the appropriate indices in your matrices A and b.

    Something along the lines of

        b(index1,index2) = -Demand(j,i);
    

    where index1 and index2 specify the position in b at which you want them stored. By storing the value at a particular (appropriate) element in the matrix b rather than overwriting it each time as you currently are, you should get what you want by working out the appropriate indices at each iteration. Similarly if A is 3 dimensional array then you need something similar but with 3 indices.

    I cannot give you an in code solution as you have 4 loops here and it is not clear to me exactly what data you are storing. Maybe someone else can give you an exact line for line solution, but if not I hope this provides enough help for you to see what needs to be done to fix the problem.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have following code in my application: // to set tip - photo in
I have following code in my Application. Comments in my code will specify My
I have following code in my application. [self.navigationController pushViewController:x animated:YES]; It will push a
I have following code class User attr_accessor :name end u = User.new u.name =
i have following code to show div on page <div id=all_users> <div id=user11 userid=11
We have following code: try { // some code throwing MyException } catch (MyException
I have following code snippet that i use to compile class at the run
I have following code: public static void ProcessStep(Action action) { //do something here if
I have following code: private void ProcessQueue() { foreach (MessageQueueItem item in GetNextQueuedItem()) PerformAction(item);
I have following code snippet: class ABC{ public: int a; void print(){cout<<hello<<endl;} }; int

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.