MATLAB error(abcdchk(a,b,c,d)); What does this mean? - matlab

What does the code
error(abcdchk(a,b,c,d));
in MATLAB do? I'm trying to run a MATLAB script with this code snippet in Octave and getting
error: 'abcdchk' undefined near line 57 column 7
error: evaluating argument list element number 1
How can I fix this?

There appear to be multiple versions of the abcdchk() function out there (kind of depends on where you got the code from), for example this one from caltech and this one from Georgia Tech, but they all seem to check that the dimensions of the given matrices are consistent.

Related

getting error in reshap command in Matlab

I am coding a script and I need to use reshape command.
This is my code:
Bit_Num=4;
FFT_Num=64;
Carrier_Num=48;
OFDM_per_Symbol=1;
CP=16;
LI=12 ;
Np=4; % Number of pilot
Carriers=1:Carrier_Num+Np;
N_Num=Bit_Num*Carrier_Num*OFDM_per_Symbol;
BitTx=randi(1,N_Num);
N_Num=length(BitTx);
SymQAMtmp=reshape(BitTx,4,N_Num/4).';
I was coding with Matlab 2015 and it was okay. However, I need to run my code in Matlab 2017.
I got this error:
Error using reshape
To RESHAPE the number of elements must not change.
can anyone help me to fix this problem?
You should read how 'randi' works. type 'help randi' to see that randi(1, N_Num) generates N_Num x N_Num matrix containing all elements '1'.

Why do I get an error within matlab(octave) using the vpi package using rdivide, mrdivide or quotient?

I am using octave for private use(I'm a student and there is unfortunately no free version of Matlab for students at my university)
Now I try to implement an algorithm using big numbers; So I started downloading the vpi package here:
http://www.mathworks.com/matlabcentral/fileexchange/22725-variable-precision-integer-arithmetic
Now I put the data in the right place and started working with it which was really great;
So I started for example with:
a=vpi(12989487973402)
a =
12989487973402
and then
a=a^10
a = 1367477916402329222848766554412698316550418920659968300260110320792
46979577273468682364762841107165766713454228653820366806955009024
which works really awesome; However I try now to use one of the commands rdivide, mrdivide or quotient of this package which is actually made for vpi numbers and should actually work; However it doesn't work with bigger numbers:
E.g.
b=vpi(129892);
c=b^2
c =
2191528947700288
rdivide(c,2)
ans =
1095764473850144
However when the numbers only a little bigger, I suddenly get error messages (with functions rdivide, mrdivide and quotient exactly the same ones)
c=b^4
c =
284662078074685808896
rdivide(c,2)
error: 'iszero' undefined near line 49 column 6
error: called from:
error: /home/john/test/#vpi/times.m at line 55, column 3
error: /home/john/test/#vpi/mtimes.m at line 27, column 7
error: evaluating argument list element number 1
error: /home/john/test/#vpi/quotient.m at line 103, column 9
>>>error: /home/john/test/#vpi/rdivide.m at line 43, column 5
Now I'm wondering if it is a problem of Octave and I need to have the original matlab or if it is a bug in the program or if I'm too stupid to use it???
Can someone help??? Thank you
EDIT: rdivide, mrdivide and quotient are working all very similar and they are supposed to return a./b for rdive/mrdivide/quotient(a,b) if a is divisible by b

Unable to use "range" function in MATLAB

I need the range of a vector. From the MATLAB documentation, it says "For vectors, range(x) is the range of the elements." However, whenever I try to use it, I get the error "Undefined function 'range' for input arguments of type 'double'." For example, if I use x=[1 2 3 4 5] and then do range(x), I will get this error. Am I crazy or is MATLAB screwing up here? I'm usually pretty good at figuring things out on my own but this one is stumping me.

Making scatter plots from structs in MATLAB

I'm trying to write a bit of code of to make MATLAB scatter plots from variables in a structure. I want to give the code the name of the structure (there will be many of these structures) and then get it to make a scatter plot of two variables. When I try the code below I get an error message saying, "??? Error: File: make_graphs.m Line: 6 Column: 9
The input character is not valid in MATLAB statements or expressions."
str2stuct= input('Please enter the string for the struct e.g. TMB_RUN_1_data:');
test1=strcat(str2stuct,'.NDROP_max');
test2=strcat(str2stuct,'.input_kappa');
scatter($(test2), $(test1))
I thought that the error message probably meant that I was using the dollar sign in a way which MATLAB doesn't approve of (I've yet to find much use for $ in MATLAB).
I tried it like this:
str2stuct= input('Please enter the string for the struct e.g. TMB_RUN_1_data:');
test1=strcat(str2stuct,'.NDROP_max');
test2=strcat(str2stuct,'.input_kappa');
scatter((test2),(test1))
And got this error:
"??? Error using ==> scatter at 51
Must supply X and Y data as first arguments.
Error in ==> make_graphs at 6
scatter((test2),(test1)) "
I tried it with changing the last line as shown below but got the same error as with the brackets:
scatter(test2,test1)
If I use the literal name as below it works fine.
scatter(TMB_RUN_1_data.NDROP_max,TMB_RUN_1_data.input_kappa)
I've tried a bunch of other things but I am not getting it. I've tried the mathworks pages on scatter but there are no examples that are close to what I am doing. I am really really stuck.
EDIT: I have found a solution but I am aware that this is not considered best practice. If you can simply explain how to do this better that would be good. Answers should be aimed at a moron in a hurry, not an experienced programmer.
Making this the last line works:
scatter(eval(test2),eval(test1))
I am aware that 'eval' is frowned upon and so this probably isn't a good long term answer, works for now. This seems to be the way to get MATLAB to actually read the contents of the strings test1 and test2 into the lines in question.

keving murphy's hmm matlab toolbox assertion error

I am working on a project that needs to use hidden markov models. I downloaded Kevin Murphy's toolbox. I have some problems about the usage. In the toolbox webpage, he says that first input of dhmm_em and dhmm_logprob are symbol sequence data. On their examples, they give row vectors as data. So, when I give my symbol sequence as row vector, I get error;
??? Error using ==> assert at 9
assertion violated:
Error in ==> fwdback at 105
assert(approxeq(sum(alpha(:,t)),1))
Error in ==> dhmm_logprob at 17
[alpha, beta, gamma, ll] = fwdback(prior,
transmat, obslik, 'fwd_only', 1);
Error in ==> mainCourseProject at 110
loglik(train_act) =
dhmm_logprob(orderedSymbols,
hmm{train_act}.prior,
hmm{train_act}.trans,
hmm{act}.emiss);
However, before giving this error, code works for some symbol vectors. When I give my data as column vector, functions work fine, no errors. So why exactly am I getting this error?
You might say that I should be giving not single vectors, but vector sets, I also tried to collect my feature vectors in a struct and give row vectors as such, but nothing changed, I still get assertion error.
By the way, my symbol sequence does not have any zeros, I am doing everything almost the same as they showed in their examples, so I would be greatful if anyone could help me please.
Im not sure, but from the function call stack shown above, shouldn't the last line be hmm{train_act}.emiss instead of hmm{act}.emiss.
In other words when you computing the log-probability of a sequence, you should pass components that belong to the same HMM model (transition matrix, emission matrix, and prior probabilities).
By the way, the ASSERT in the code is a sanity check that a vector of probabilities should sum to 1. Oftentimes, when working with very small values (log-probabilities), numerical stability issues can creep in... You could edit the APPROXEQ function to relax the comparison a bit, by giving it a bigger margin of error
This error message and the code it refers to are human-readable. An assertion is a guard put in by the programmer, to ensure that certain conditions are met. In this case, what is the condition? approxeq(sum(alpha(:,t)),1) I'd venture to say that approxeq wants the values to be approximately equal, so this boils down to: sum(alpha(:,t)) ~= 1
Without knowing anything about the code, I'd also guess that these refer to probabilities. The probabilities of a node's edges must sum to one. Hopefully this starts you down a productive debugging path. If you can't figure out what's wrong with your input that produces this condition, start wading into the code a bit to see where this alpha vector comes from, and how it ended up invalid.