Create a random logical vector of N elements of which M are true. - MATLAB Cody - MATLAB Central

Problem 1090. Create a random logical vector of N elements of which M are true.

Difficulty:Rate

Your task for tomorrow is to create a random binary (logical) vector of N elements of which M are true.

For example:

random_binary(10,4)

could result in

[1 0 0 1 1 0 0 0 1 0]

This task is related to problem 1089.

Solution Stats

35.37% Correct | 64.63% Incorrect
Last Solution submitted on Dec 07, 2024

Problem Comments

Solution Comments

Show comments
PIVlab surpasses 100K all-time File Exchange downloads
During the past twelve months, PIVlab, a MATLAB Community Toolbox for particle...
4
7
LLMs with MATLAB updated to support the latest OpenAI Models
Large Languge model with MATLAB, a free add-on that lets you access...
2
4

Problem Recent Solvers102

Suggested Problems

More from this Author31

Problem Tags

Community Treasure Hunt

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

Start Hunting!
Go to top of page