MATLAB Answers


Why error function not work?

Asked by Amna El-tawil on 15 Nov 2018
Latest activity Commented on by madhan ravi
on 15 Nov 2018
The error function doesn't work with me. I do not get any result.
If anyone knows the problem, I will be thankful
for j1=1:3,
yi=w'*x(:,j1); % Network output
if sum(y-d(1,:)') > 0


on 15 Nov 2018
The apostrophe transposes that output of d:
size(d(1,:)) % -> [1 3]
size(d(1,:)') % -> [3 1]
So neither will actually fit.
What are you trying to do? If you give a good description of your problem, we can try to help you with that, instead of fixing code that might not do what you mean.
It is very unlikely that the code shown does whatever it is required to do. The whole thing doesn't make sense. Of course, if the code was commented as it should be, we would have an idea of what it was supposed to do (hint!).
Madhan: size(y) is 4 by 1
Amna: size(y) is 4 by 3
size(y) is always going to be size(w, 2) by 1. It can't have 3 columns since the multiplication in w' * x(:, 1) guarantees it will have one column. It will has as many rows as w has column, which is no whose value was not given. If no is 3 the subtraction will succeed. ni has to be 4 for the multiplication to work.
Also note that naming a variable error is a bad idea. It's already the name of a matlab function.
Perfect explanation @Guillaume

Sign in to comment.


0 Answers