how to fix this easy digital communication excercise using MATLAB - function

I have a problem in writing in MATLAB a program that modulates data bits, adds noise then demodulates it and calculate the bit error and the symbol error rate. The modulation used first should be QPSK. I have done the following,
N=100;
databits = randi([0 3],N,1);
hModulator = comm.QPSKModulator;
hModulator.PhaseOffset = pi/4;
txsig = step(hModulator, databits);
scatterplot(txsig)
grid on
SNRdB=-10
rxsig = awgn(txsig,SNRdB);
H = comm.QPSKDemodulator
hH.PhaseOffset = pi/4;
symdecoded=step(H,rxsig)
symerr(symdecoded,databits)
biterr(symdecoded, databits)
My first question is I don't think I am doing the bit error rate and symbol error rate correctly, can someone help me spot where the problem is? Where am I missing out?
I am then asked to repeat the same problem but make the changes needed to make it work with 16-QAM and 64-QAM by changing a parameter called CONSTELLATION.
I have tried using demod and ddemodce but these two functions are removed from matlab? Does anyone know how to proceed?

I dont know why you are using SNRdB=-10 dB?
Try for example positive numbers 0 10 20 30, and you may save symerr and biterr as the function proposes [number,ratio] = symerr(x,y)
number= numb of error and ratio = bitsTx/bitsRx
For m-qam better use modem.qammod try the help in matlab
Best regards and good luck

Related

Facing problem while performing basic STL vector program

I am trying to implement a basic STL vector program but I am getting an error I can't understand and can't find a convincing solution either.Here is the image of the code
Here is the error:
*no suitable conversion function from "__gnu_cxx::__normal_iterator<int , std::vector<int, std::allocator>>" to "int" exists
Also, if someone can, please explain me the problem too so that I can prevent this in future?
If you look at cppreference, you'll see that max_element returns an iterator to the maximum element in the sequence.
That's not an int; when you try to assign it to an int, it fails, and gives you a message telling exactly why it's failing.

Linear function with live data

I am an absolute newbie on the programming thing and really desperate. I picked up a high end task to solve as it seems to me...
I know there are tons of explanations for solving y = mx + b with python but they're all for the situation with "solid" data. I am trying to realize it with live data.
So far, i have two data streams, which I successful directed into two lists - please see code below.
for graph in basis_graph:
high_1 = float(graph.high)
low_1 = float(graph.low)
if high_1 > 0:
graph_high.append([high_1])
if low_1 > 0:
graph_low.append([low_1])
Now comes the tricky part and I DON`T GET IT. I need a function that calculates me "m". Something like that:
def function_signal():
if graph_high[-1] < graph_high[-2]:
please, mr. computer, calculate me "m"
I tried something like
def signal():
if graph_low[-1] < graph_low[-2]:
print("a")
ay1 = graph_low[-1]
by1 = graph_low[-2]
m = ay1 - by1
return m
print(m(ay1, ay2))
Two days I tried EVERYTHING from what I know so far but the only thing I earned was a cascade of Tracebacks. From "I can't divide two list objects" to " "m" is not defined" and so on and so on...
In the case above for example NOTHING happens. Sometimes he says "m is not defined"...
Please, if there's someone out there who is willing to help me than I would really appreciate it.
Thanks in advance.

How do I use the modulo operators in Socrata SoQL?

https://dev.socrata.com/docs/datatypes/number.html#, says that % and ^ can be used to get the modulo of one number divided by another number. I cannot get them to work and cannot find examples.
When I try ^ I appear to get exponentiation. Example:
http://data.cityofchicago.org/resource/pubx-yq2d.json?$select=streetnumberto,streetnumberfrom,(streetnumberto-streetnumberfrom)^100%20as%20address_length_in_blocks
When I try % itself, I get a "malformed" error, not so surprisingly. When I try the %25 code for %, I still get a "malformed" error but one that seems to suggest that it correctly inserted the % but does not know what it means. (I am restricted from posting more than two links but just replace the ^ above with % and %25.)
Can anyone help me get this working?
By the way, at the risk of mixing topics, I would ideally like to use an int or round sort of function but they do not seem to exist in SoQL so I was trying to back into getting the integer portion of dividing by 100.
Thank you.
Great question. I just tried it myself and I'm getting a malformed exception too, and it's definitely getting through to the query optimizer:
https://data.cityofchicago.org/resource/erhc-fkv9.json?totalfees=4160%20%25%2010.0
Note I'm using the SODA 2.1 version of that API, which I recommend you migrate to:
https://dev.socrata.com/foundry/#/data.cityofchicago.org/erhc-fkv9
I'll check with our engineering team and see what might be going on. I'll pass on the feature request for round, ceil, floor, etc as well.

Matlab ode solver using the time in a function for 'value' in events

I've searched extensively, and thought I wouldn't be the only one having this problem, but it seems to look like I am.
I am solving an ode via ode15s (my problem can be stiff) and I use the 'Events' option to find my point of interest.
The problem is: the equation that I use in 'value' is depending (among other things) on the specific time (so value = f(t,y,y'), and I cannot find a way of passing the current time to this function, only the y vector is available.
Anyone has any ideas?
Thanks in advance and all the enjoy the rest of your holidays!
Sorry, made a really stupid error (used , instead of ;)...
You can just use the t argument as long as you set it in your #odefunction(t,y) as well as your #events(t,y).

As3 BigInteger returns an Incorrect Answer

I am trying to implement a RSA encryption program in flash. I looked into working with Big Numbers and found the BigInteger var type in the Crypto package. I started playing around with BigIntegers but my outputs are never the correct answer. For example the below code will output 5911 when the answer should be 9409. Any input about this error would be great.
var temp:BigInteger = new BigInteger(String(97));
temp = temp.pow(2);
trace(temp.toString());
Output = 5911
I'm not sure which crypto package you are referring to, I though it was as3crypto but I don't remember it's implementions having a pow method that has that signature. But either way, you always have to remember what base you are dealing with and what the library was designed for.
(9716)2 = 591116
You are dealing with hex, not decimal, numbers.
Think of that geek-is-chic tshirt that says "There are 10 kinds of people. Those that understand binary and those that don't". In that case "10" is assumed to be 102. Which equals 210. Unqualified bases almost always ruin everybodys day.