Confusion in matrix multiplication and dimensions
이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
오류 발생
페이지가 변경되었기 때문에 동작을 완료할 수 없습니다. 업데이트된 상태를 보려면 페이지를 다시 불러오십시오.
이전 댓글 표시
0 개 추천
Dear all, this is the least beautiful representation of a signal in dB that I have ever seen) Does anybody know for to fix it?
The first graph is the same spectrum but
UPD: This was due to a typo in matrix multiplication... Check dimensions first....

채택된 답변
Star Strider
2024년 11월 25일
댓글 수: 6
I did not quiet get you. What do you mean by matrix and which several signals are you talking about? I just have a single vector "spectrum_normalized" defined on "frequency_domain" - also vector of the same size. Why does the graph look like this? I thought it is supposed to be a line showing for each value of "frequency_domain" which value in dB of "spectrum_normalized" corresponds to it.
I get the iimpression that you are plotting a matrix. A single vector would have one line (probably blue).
That is the thing - i do not know why the graph looks like this... But still thank you a lot for your answer, I will let you know if somebody answers
It would help to have your data and your code. You can copy and paste your code to a Comment. Use the paperclip button to upload your data file here.
The sort of matrix I believe you have would be something like this —
Fs = 250;
L = 5;
f = 1:10;
t = linspace(0, Fs*L, Fs*L+1).'/Fs; % Time Vector
s = sin(t*f*2*pi)+f*2 % Signal Matrix
s = 1251×10
2.0000 4.0000 6.0000 8.0000 10.0000 12.0000 14.0000 16.0000 18.0000 20.0000
2.0251 4.0502 6.0753 8.1004 10.1253 12.1502 14.1750 16.1997 18.2243 20.2487
2.0502 4.1004 6.1502 8.1997 10.2487 12.2970 14.3446 16.3914 18.4371 20.4818
2.0753 4.1502 6.2243 8.2970 10.3681 12.4371 14.5036 16.5673 18.6277 20.6845
2.1004 4.1997 6.2970 8.3914 10.4818 12.5673 14.6471 16.7203 18.7863 20.8443
2.1253 4.2487 6.3681 8.4818 10.5878 12.6845 14.7705 16.8443 18.9048 20.9511
2.1502 4.2970 6.4371 8.5673 10.6845 12.7863 14.8702 16.9343 18.9773 20.9980
2.1750 4.3446 6.5036 8.6471 10.7705 12.8702 14.9430 16.9867 18.9999 20.9823
2.1997 4.3914 6.5673 8.7203 10.8443 12.9343 14.9867 16.9993 18.9716 20.9048
2.2243 4.4371 6.6277 8.7863 10.9048 12.9773 14.9999 16.9716 18.8938 20.7705
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
figure
plot(t, s)
grid
xlabel('Time')
ylabel('Amplitude')

F = repmat(f, numel(t), 1)
F = 1251×10
1 2 3 4 5 6 7 8 9 10
1 2 3 4 5 6 7 8 9 10
1 2 3 4 5 6 7 8 9 10
1 2 3 4 5 6 7 8 9 10
1 2 3 4 5 6 7 8 9 10
1 2 3 4 5 6 7 8 9 10
1 2 3 4 5 6 7 8 9 10
1 2 3 4 5 6 7 8 9 10
1 2 3 4 5 6 7 8 9 10
1 2 3 4 5 6 7 8 9 10
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
T = repmat(t, 1, numel(f))
T = 1251×10
0 0 0 0 0 0 0 0 0 0
0.0040 0.0040 0.0040 0.0040 0.0040 0.0040 0.0040 0.0040 0.0040 0.0040
0.0080 0.0080 0.0080 0.0080 0.0080 0.0080 0.0080 0.0080 0.0080 0.0080
0.0120 0.0120 0.0120 0.0120 0.0120 0.0120 0.0120 0.0120 0.0120 0.0120
0.0160 0.0160 0.0160 0.0160 0.0160 0.0160 0.0160 0.0160 0.0160 0.0160
0.0200 0.0200 0.0200 0.0200 0.0200 0.0200 0.0200 0.0200 0.0200 0.0200
0.0240 0.0240 0.0240 0.0240 0.0240 0.0240 0.0240 0.0240 0.0240 0.0240
0.0280 0.0280 0.0280 0.0280 0.0280 0.0280 0.0280 0.0280 0.0280 0.0280
0.0320 0.0320 0.0320 0.0320 0.0320 0.0320 0.0320 0.0320 0.0320 0.0320
0.0360 0.0360 0.0360 0.0360 0.0360 0.0360 0.0360 0.0360 0.0360 0.0360
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
figure
plot3(F, T, s, LineWidth=2)
grid on
xlabel('Frequency')
ylabel('Time')
zlabel('Amplitude')

This is the sort of plott I would expect it to display.
.
I figured out the spectrum normalized was in reality a matrix, not a vector, exactly as you have said! It was due to a transposed by mistake matrix in multipllication by which the spectrum_normalized was obtained.
Thank you for your answers and explanations! Sorry for the confusion... Checking dimensions matters, I consider it as a lesson.
As always, my pleasure!
No worries! I have confronted the same sort of problem in the past, that being the reason I saw it here.
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Axis Labels에 대해 자세히 알아보기
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
