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 8438133
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T07:37:27+00:00 2026-06-10T07:37:27+00:00

Guys I have problem to make a random matrix by considering some constraint and

  • 0

Guys I have problem to make a random matrix by considering some constraint and another matrix.

I have matrix :

A= [ 1 4 3 5 2 6 8 7 10 11 12 9;
     4 1 2 3 6 5 9 8 7 10 11 12;
     1 2 3 4 5 6 12 9 8 10 11 7]

then, i want to make a matrix B (3,12) which has value between 0 and 2 ([ 0 2]) randomly.
but there is some constraint :

a. no consecutive zeros (0) more than 2.
b. sum all element in each row in matrix B <=11,
c. if there is value 1 or 2 or 3 or 4 in coordinate (a,b) in matrix A. so we have to force in coordinate(a,b+1) in matrix B have value zero (0).

thanks for your help before guys.

  • 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-10T07:37:28+00:00Added an answer on June 10, 2026 at 7:37 am

    So, if you use this answer, to generate a B which fulfills the constraints 1 and 2, you can use something similar to this

    B = rand(3, 12); %# Just an example matrix.
    idx = bitand(A >= 1, A <= 4);
    B([false(size(idx, 1), 1) idx(:,1:end-1)]) = 0
    

    to enforce the third constraint.

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

Sidebar

Related Questions

I hope some of you guys can help me with this problem.... I have
i guys i have a problem, i want to run a haskell script that
I have a little problem here: I want to make a button in my
OK guys, here's my problem. I have a navigation bar on my website, which
Hi guys i have a problem i my code i set a datepicker with
guys. I have a strange problem. I try to write unit-tests to web-app. I
Ok guys, I have a serious problem with this. I have a static class
Hey guys, I have a weird problem. I have an update system that refreshes
hey guys having this really simple problem but cant seem to figure out have
i have a problem guys i made a wpf applications its running well but

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.