how to craete a matrix with desired elements

1 次查看(过去 30 天)
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 .

采纳的回答

Matt Fig
Matt Fig 2012-10-17
编辑:Matt Fig 2012-10-17
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 个评论
MANJUNATH
MANJUNATH 2012-10-17
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 2012-10-17
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 .

请先登录,再进行评论。

更多回答(1 个)

Sachin Ganjare
Sachin Ganjare 2012-10-17
What exactly is your requirment, please elaborate.
  1 个评论
MANJUNATH
MANJUNATH 2012-10-17
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

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by