If C =
0 0 0.0244 0 0.0260 0 0.0136 0 0 0
0.1738 0 0 0 0 0.0240 0 0.0629 0 0
0 0 0 0 0 0 0 0 0 0
0 0.0662 0 0.0890 0 0 0 0 0.0181 0.0472
B = reshape(repmat(max(reshape(C,2,[])),C,1),size(C))
I am getting
Error using repmat
Replication factors must be a row vector of integers or integer scalars.
How to overcome it.

댓글 수: 3

Stephen23
Stephen23 2017년 12월 18일
See original question and (working) answers here:
@Prabha Kumaresan: I notice that you copied my code and changed it so that it does not work anymore. What was the purpose of that change?
Guillaume
Guillaume 2017년 12월 18일
@Prabha
  • your profile show that you've asked 94 questions and accepted 0 answers, which would mean you that either you never got a correct answer, a worrying fact, or that you don't care about rewarding people who help you, in which case why should we bother?
  • Looking at a few of your questions they barely include enough information to be able to answer you. There's no explanation of what you're trying to do, just some random code that doesn't work. Spend more time on your question
  • More importantly, spend more time understanding the answers you've given and spend more time learning matlab. Read the documentation of each function used in the answers you're given and understand how the answer works.
Prabha Kumaresan
Prabha Kumaresan 2017년 12월 18일
since i am unable to get the result i am asking again.

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

답변 (2개)

Walter Roberson
Walter Roberson 2017년 12월 18일

0 개 추천

Your repmat call is
repmat(max(reshape(C,2,[])),C,1)
The part
max(reshape(C,2,[]))
tells MATLAB to start by reshape C to 2 rows, then find the maximum per column, giving a row vector (of 20 elements).
Then the repmat( max(...), C, 1)
tells it to repeat the vector C times along the rows. But C is floating point numbers.
Considering that you reshaped C to 2 x N, and took the max along columns to get 1 x N, in order for the reshape() you are about to do after this to work, you would need to repeat by 2:
repmat(max(reshape(C,2,[])),2,1)

댓글 수: 8

Prabha Kumaresan
Prabha Kumaresan 2017년 12월 18일
편집: Stephen23 2017년 12월 18일
if C =
0 0 0 0 0 0.0086 0.0061 0 0.0039 0
0.0106 0 0 0.0143 0.0272 0 0 0 0 0
0 0 0.0030 0 0 0 0 0.0035 0 0
0 0.0003 0 0 0 0 0 0 0 0.0002
I want to have output such that the first two rows should have same values and last two rows should have same values.
Prabha Kumaresan
Prabha Kumaresan 2017년 12월 18일
if i am having (m*n) array then how repmat can be used.
Stephen23
Stephen23 2017년 12월 18일
@Prabha Kumaresan: by reading the repmat documentation, and correctly applying it to your array.
Guillaume
Guillaume 2017년 12월 18일
how repmat can be used
To do what?
Again, give a lot more details about what you want to achieve
Prabha Kumaresan
Prabha Kumaresan 2017년 12월 18일
This was the coding which i am trying to solve siz = size(G) idx = sub2ind(siz, randi([1,10], 1, siz(2)), 1:siz(2)); C = zeros(siz); C(idx) = G(idx)
where C and G are attached as image below.
G and C are matrix of (Number of users,Number of subcarriers),(10*50)
I need to do random user grouping such that subcarriers of the grouped users need to get shared.
for that experts told me to use B = reshape(repmat(max(reshape(C,2,[])),C,1),size(C))
(or)
[ii,jj] = find(C) B = C B(sub2ind(size(C),rem(ii + 1,4)+1,jj)) = C(C>0)
But i am unable to get the result.Please help me to get out of this issue.
Stephen23
Stephen23 2017년 12월 18일
편집: Stephen23 2017년 12월 18일
"experts told me to use B = reshape(repmat(max(reshape(C,2,[])),C,1),size(C))"
I can't find that particular code anywhere in the original question. Can you please provide a link to this ?
I did find my (working) code that is very similar to this, but clearly you have changed it and have so far not offered any reason for that change.
Prabha Kumaresan
Prabha Kumaresan 2017년 12월 18일
the code which u gave worked separately for an array.but when i tried to implement on my code it doesnt work.
Stephen23
Stephen23 2017년 12월 18일
" i tried to implement on my code it doesnt work"
It worked when I tried it using the data that you provided.

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

Stephen23
Stephen23 2017년 12월 18일
편집: Stephen23 2017년 12월 18일

0 개 추천

>> B = reshape(repmat(max(reshape(C,2,[])),2,1),size(C))
ans =
0.17380 0.00000 0.02440 0.00000 0.02600 0.02400 0.01360 0.06290 0.00000 0.00000
0.17380 0.00000 0.02440 0.00000 0.02600 0.02400 0.01360 0.06290 0.00000 0.00000
0.00000 0.06620 0.00000 0.08900 0.00000 0.00000 0.00000 0.00000 0.01810 0.04720
0.00000 0.06620 0.00000 0.08900 0.00000 0.00000 0.00000 0.00000 0.01810 0.04720

댓글 수: 1

Stephen23
Stephen23 2017년 12월 18일
@Prabha Kumaresan: note that this is exactly the same as my answer to your earlier question, whose code you copied and changed (without any obvious reason).
Remember that we are volunteers here and you can show your appreciation of our time that we volunteer to help you by accepting the answer that best resolves your question.

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

카테고리

도움말 센터File Exchange에서 Matrix Indexing에 대해 자세히 알아보기

태그

질문:

2017년 12월 18일

댓글:

2017년 12월 18일

Community Treasure Hunt

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

Start Hunting!

Translated by