Hi guys,
Please can anyone help me with this problem. It is an old homework and I want to practice.
This is it:
It may seem that we need the relational operators (<, >, etc.) to make decisions, but this is not necessarily true. The sign function can often be used to do the job. For example, suppose we want to compute the number of positive elements in a vector u. The sequence of commands w=sign(u)+0.5, v=fix(w); sum(v); will produce the desired value (try it!). Use this idea and define a Matlab function mycompare(u,v) that will compute the percentage of the components of the input vector u that are bigger than the corresponding component of the input vector v. You may assume that u and v are the same size vectors. Rememberno explicit loops or conditionals are allowed!
Thank you for helping me .
Braddy
Please can anyone help me with this problem. It is an old homework and I want to practice.
This is it:
It may seem that we need the relational operators (<, >, etc.) to make decisions, but this is not necessarily true. The sign function can often be used to do the job. For example, suppose we want to compute the number of positive elements in a vector u. The sequence of commands w=sign(u)+0.5, v=fix(w); sum(v); will produce the desired value (try it!). Use this idea and define a Matlab function mycompare(u,v) that will compute the percentage of the components of the input vector u that are bigger than the corresponding component of the input vector v. You may assume that u and v are the same size vectors. Rememberno explicit loops or conditionals are allowed!
Thank you for helping me .
Braddy