Input of array into equation update
2 次查看(过去 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 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!