Hey guys,
I'm looking for a little help with a problem that I can't seem to find anyone else having, probably because it's so simple that it can be solved by someone with decent experience very quickly.
I have a matrix with a bunch of numbers. This is not an image, rather the result of calculations for a value of each cell. In all cases, the cell contains either a zero or some decimal value ie 0.006.
What I need to get is an output of three columns; column number(x)/row number(y)/original value of the cell(ie 0.1).
Any help would be appreciated,
Cheers Marty

 채택된 답변

Titus Edelhofer
Titus Edelhofer 2014년 11월 25일

1 개 추천

Hi Martin,
are you looking for something like this:
>> A = rand(2,3)
A =
0.2020 0.3507 0.0538
0.2103 0.1068 0.4271
>> [col,row] = meshgrid(1:size(A,2), 1:size(A,1));
>> [col(:) row(:) A(:)]
ans =
1.0000 1.0000 0.2020
1.0000 2.0000 0.2103
2.0000 1.0000 0.3507
2.0000 2.0000 0.1068
3.0000 1.0000 0.0538
3.0000 2.0000 0.4271
Titus

댓글 수: 1

Martin
Martin 2014년 11월 26일
Yes! thankyou so much, Titus. Works perfectly :) Thanks!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

질문:

2014년 11월 25일

댓글:

2014년 11월 26일

Community Treasure Hunt

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

Start Hunting!

Translated by