how to craete a matrix with desired elements

3 visualizaciones (últimos 30 días)
MANJUNATH
MANJUNATH el 17 de Oct. de 2012
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 .

Respuesta aceptada

Matt Fig
Matt Fig el 17 de Oct. de 2012
Editada: Matt Fig el 17 de Oct. de 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 comentarios
MANJUNATH
MANJUNATH el 17 de Oct. de 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 el 17 de Oct. de 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 .

Iniciar sesión para comentar.

Más respuestas (1)

Sachin Ganjare
Sachin Ganjare el 17 de Oct. de 2012
What exactly is your requirment, please elaborate.
  1 comentario
MANJUNATH
MANJUNATH el 17 de Oct. de 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

Iniciar sesión para comentar.

Categorías

Más información sobre Loops and Conditional Statements en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by