Input of array into equation update
조회 수: 1 (최근 30일)
이전 댓글 표시
I need to update a simple Matlab code shown below. What the code is doing is converting dB values to its respective magnitude ranging from 0dB to 20dB in increments of 0.5dB. This is done in the third line of code for the b variable. I ran it without the semicolon and all 40 values were correct. However, I want the last line of code to take those 40 magnitude values and calculate them into the variable v equation. When I ran the code the 40 values produced did not match my calculator calculations. Is there a better way for me to run through the loop of 40 magnitude values into the last equation for variable v? Can someone please update this code maybe with a for loop or anything you can recommend? I am calculating the variance values from the SNR values that were converted to their magnitudes. This is for a 4-QAM modulation. Thank you in advance!
a = 4;
x = (0:0.5:20);
b = 10.^(x/10);
v = 2*a^2./(b)
댓글 수: 0
채택된 답변
Joseph
2023년 4월 4일
A couple of thoughts here. First the small nuance that "x" is actually a vector of length of 41. Second you mention that you are attempting to go from dB values to magnitude, however you are using the formula for dB to power. This could be how you are getting different answers. To try it with the strictly "db-to-magnitude" forumula, just change the third line.
a = 4;
x = 0:0.5:20;
b = 10.^(x./20); %note the 20 instead of the 10
v = 2*a.^2./b;
Otherwise I cannot replicate the difference in answers with and without semicolons that you described.
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Shifting and Sorting Matrices에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!