필터 지우기
필터 지우기

Matrix dimension must agree error

조회 수: 1 (최근 30일)
Ayesha Punjabi
Ayesha Punjabi 2018년 10월 17일
답변: Guillaume 2018년 10월 17일
  • >> Data1 = 0
  • >> spreadcodefor1 = [1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0];
  • >> result1 = xor(Data1,spreadcodefor1);
  • >> Data2 = 1
  • >> spreadcodefor2 = [1 1 0 0 0 0 1 1 0 0 1 1 1 1 0 0];
  • >> result2 = xor(Data2,spreadcodefor2);
  • >> allresult = result1 + result2;
  • >> SNR = 7;
  • >> Noise(1:48) = SNR * rand(1,1);
  • >> allnoise = allresult + Noise;
the last statement shows error saying matrix dimensions must agree. I do not know why is this happening. Kindly help

채택된 답변

Guillaume
Guillaume 2018년 10월 17일
I do not know why is this happening
Allresult is 1x16, Noise is 1x48(assuming it didn't exist before you create it). Of course, at the error message tells you, you can't add vectors of different size.
It's really unclear why you create a noise vector with 48 elements.
Noise = rand(size(allresult)) * SNR;
would ensure that Noise always has as many elements as allresult.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by