필터 지우기
필터 지우기

how to craete a matrix with desired elements

조회 수: 1 (최근 30일)
MANJUNATH
MANJUNATH 2012년 10월 17일
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에서 Convert Image Type에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by