how to craete a matrix with desired elements

1 view (last 30 days)
in case of magic(n) and rand(n) an n by n matrix is created wit magic and pseudorandom elements respectively ,
how i can create a matrix of my choice(rows and col.) and with user defined elements in it .

Accepted Answer

Matt Fig
Matt Fig on 17 Oct 2012
Edited: Matt Fig on 17 Oct 2012
Many ways! What do you have in mind exactly?
In the most general form:
function A = makematrix()
% Help user create an array.
% Note, error checking not written yet.
R = input('Enter the number of rows: ');
C = input('Enter the number of columns: ');
A = zeros(R,C);
for ii = 1:R
for jj = 1:C
S = sprintf('Enter element at (%i,%i): ',ii,jj);
A(ii,jj) = input(S);
end
end
  2 Comments
MANJUNATH
MANJUNATH on 17 Oct 2012
i have a 32 by 32 pixels, i have to address(using binary values) each pixel , obtain their output and display as an image (gray scale ) for which can use imshow , actually image has to contain 32 by 32 pixels
i am finding it difficult in addressing , i use bvdata=logical[0 0 0 0 0 0 0 0 0 0 ] putvalue=(dio,bvdata) to address each pixel , so similarly i have to address all 1024 pixels in one sec and repeat the process .
MANJUNATH
MANJUNATH on 17 Oct 2012
Sir,
i have a sensor with 32 by 32 pixels , addressing each pixel gives me the voltage value of that pixel as an output, that obtained output has to be displayed in the form of an gray scale image(imshow with 32 rows and 32 col.). Addressing individual pixel should be so fast that within 1 sec all 1024 pixel has to be addressed and their output is displayed . This scan has to repeat after every second.
To address one single pixel i used bvdata=logical[0 0 0 0 0 0 0 ..] putvalue=(dio,bvdata).
but now i have make a loop so that each and every pixel is addressed and corresponding output is displayed .

Sign in to comment.

More Answers (1)

Sachin Ganjare
Sachin Ganjare on 17 Oct 2012
What exactly is your requirment, please elaborate.
  1 Comment
MANJUNATH
MANJUNATH on 17 Oct 2012
i want to create matrix with 32 rows and 32 columns , the elements will be data obtained from the analoginput to the DAQ
where each element corresponds to each pixel of a sensor

Sign in to comment.

Categories

Find more on Creating and Concatenating Matrices in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!