Ask an expert. Trust the answer.

Your academic and career questions answered by verified experts

Create matrix with random binary element in matlab

Date: 2022-07-18 11:00:21

I want to create a matrix in matlab with 500 cell (50 row,10 column ), How I can create and initialize it by random binary digits? I want some thing like this in 50*10 scale as sample 3*4

0 1 1 1
0 0 0 0
1 1 1 1

and after it, how can get decimal equation of any row ? like row 1 is equal 7 in decimal 

Answers: 

Why not use randi to generate random integers? 

 

A = randi([0 1], 50, 10);

and to convert a binary row to a number - as in the previous answers: 

 

 bin2dec(num2str(A(n,:))) 

 


Why Matlabhelpers ?

Our Matlab assignment helpers for online MATLAB assignment help service take utmost care of your assignments by keeping the codes simple yet of high-quality. We offer the most reliable MATLAB solutions to students pursuing their Computer Science course from the Monash University, the University of Sydney, the University of New South Wales, the University of Melbourne; to name a few. Approach us today for best Matlab solutions online!

whatsApp order on matlabhelpers.com

telegram order on matlabsolutions.com