I am trying to convert MATLAB code to C/C++. My code generates successfully and the Mex is built, but fails while running the test file with MEX. Below is the function and the error message I am receiving.
function[A1, B2, C3, D4, E5, F6] = fcn(one, two, three, four, five, six, seven, eight, nine)
Caused by:
Function 'Numbers' called with wrong number of arguments: expected 9, received 0.
Related
I am new to the the AB PLC programming and would like to know if this:
rung with branches is equivalent to this: separated into rungs
Thanks.
They are NOT Equivalent.
There are differences in the comparators (EQU) for each line (Network), while the first one only compares [50 = Wrq_Seq...], the other program compares with different values (50, 51 and 52).
There is also difference in MOV block at the end of the line, while the first one writes [60 > Wrq_Seq], the other writes different values for each situation (51, 52 and 60)
The question asked to:
Create a Huffman tree and codes for the following numbers: 24, 55, 13,
67, 88, 36, 17, 61, 24, 76
So I created this tree:
But since there are multiple trees possible, how will I know whether my tree is right or not as there are multiple elements with same frequency?
Interpreting the "numbers" as symbols as opposed to frequencies, we then have the set of frequencies {1, 1, 1, 1, 1, 1, 1, 1, 2}. Due to having more than one choice at some of the steps in the Huffman algorithm, there is more than one possible resulting topology. Here are the three topologically distinct trees you can get, depending on the choices you make:
For each of those, you can arbitrarily choose which of your symbols to put at each length. For the first two trees, the 2 has to be symbol 24, but the remaining eight symbols can be split however you like among each group of four. For each of those two trees, that is 70 possible unique length assignments. For the third tree, again the 2 has to be symbol 24, but the remaining symbols can be split as you like into the groups of two and six, for 28 possible choices.
Having made those choices, you now can assign codes to each leaf, where at each branch you can independently and arbitrarily assign 0 to the left branch and 1 to the right branch, or 1 to the left branch, and 0 to the right branch. For each tree and symbol lengths assignment, that gives 256 possible code assignments.
All told, there are 43,008 possible codes that can result from the Huffman algorithm. All of these choices are correct. They all result in the same optimal number of bits in the message (32).
Here is another example of multiple Huffman tree topologies for a single set of frequencies.
x^y (x power y) key on HP prime calculator when running in RPN mode seems to have flipped x, y values on the stack.
In other words, for a normal HP RPN calculator: 3 enter 4 x^y will give 4^3 = 64. But HP prime gives 3^4 = 81.
Is this a bug or a feature?
It's a feature. Here's the source of your very understandable confusion:
On "old school" RPN calculators (includes the 15C), the stack had only 4 elements, from bottom to top, X, Y, Z, and T. "T" would replicate when the stack dropped to allow for calculations using a "constant."
Y^X on those calculators was labeled as such because you would first enter your base then the exponent followed by the operation, leaving the Y argument in the "Y" stack register and the "X" argument in the "X" stack register. Hence 3 Enter 4 "Y^X" would give 81.
On the new calculators, there is a massive stack (something I personally saw no use for--I never ran out of stack space doing calculations on the old stack EVER in decades of advanced calculations). It made the prior constant calculations impossible on the new calculators without programming. The elements are now simply numbered 1, 2, 3, 4, 5, etc. For entry order, they figured input order of variables should be alphabetic, hence x^y. Since there are no longer stack labels, there is no longer a contradictory model of a Y register and an X register as before, so 3 Enter 4 "X^Y" still gives 81, but there is no contradictory register entry here, just a memory of how an older machine labeled its registers. I don't think many would have mistaken things if it were still labeled "Y^X" as before, and I'm personally not fond of the change, but I can understand the motivation. It is not a bug.
Both hp 48sx and hp 50g return 81 for the op's exmaple. The keys are labeled y^x, not x^y. I'm not sure at what point HP changed this.
When I run an app where an icon, wrapped in a Positioned is drawn on a container, I get an error stating that the offset, (Positioned's left) uses a NaN value. I took a look online and I found that NaN means Not a Number, but I couldn't find what causes it. I mean, If I divide a number by Zero I'll get an error saying that I cannot divide a number by zero, but NaN is a constant for what I understood, and if I was multiplying a number let's say for a string I'd get incompatible types error, instead of NaN. I'm not asking for an answer specific for my code as I couldn't provide it, but rather a more general explanation.
NaN could be caused by dividing by a variable which cannot be cast to a numbe as #JoSSte stated.
But as I found out empirically, Flutter does not throw an error while dividing by 0, as opposed to python for example where ZeroDivisionError is thrown. Flutter sees the output of a division by zero as infinity or -infinity, when dividing respectively a positive and a negative number by zero.
So this makes sense, but in instances when infinity cannot be accepted as a value (as it isn't) it throws an error stating there was an error in the framework itself.
Here is my code:
m is the length of the vector y.
1 c=1;
2 cMax=1;
3
4 while c<=m
5
6 if abs((y(c)-y(c+1)))>0.001
7 cMax=cMax+1;
8 end
9
10 c=c+1;
11 end
Essentially, vector y is a vector with a set of integers which has been organised from smallest to greatest, I'm trying to find out how many different values of y there are.
I'm comparing the current value of y to the next value of y and saving how many changes there are in cMax.
I've changed the if logic statement a few times. It has been:
if y(c)~=y(c+1)
And I reversed the if statement like this:
if y(c)==y(c+1)
%do nothing
;
else
cMax=cMax+1;
I'm not sure what I'm doing wrong but the error message is always the same:
error: A(I): Index exceeds matrix dimension.
error: called from:
error: C:\Users\dickweed\Documents\Study\Machine
Learning\Tutorials\ex3\oneVsA ll.m at line 57 [6], column 3 [way before if statement]
error: C:\Users\dickweed\Documents\Study\Machine
Learning\Tutorials\ex3\ex3.m at line 58 [7] , column 14 [after the letter c]
I've bolded where the code indicates the errors in my supplied code.
The columns are wacky, that may be because of the text editor I'm using, but I'm assuming the actual columns mean before the if statement and before the end statement.
Any help would be greatly appreciated.
PS. I'm actually using Octave, and Notepad++. The language is exactly the same, for all intents and purposes, as Matlab hence why I've labelled it Matlab.
I think that your index exceeds matrix dimensions.
Specificaly in the following line:
y(c)-y(c+1)
on the last iteration, when c=m, the second term y(c+1) tries to access an element that doesn't exist.
Suggestion: change your stop condition to:
c<m