Suppose there are two variables.
v1 = [1 2 3]; m1 = [1 2 3; 4 5 6];
I hope to create another matrix m2, having the same size with m1, and its (i, j) component is defined by
m2(i, j) = sum(v1 > m1(i, j))
In this case, clearly one solution is use "for" loop twice.
m2 = zeros(2, 3); for i = 1:2 for j = 1:3 m2(i, j) = sum(v1 > m1(i, j)); end end
test_opr = @(v, x) sum(v > x);
v1 = [1, 2, 3]; m1 = [1, 2, 3; 4, 5, 6]; your_result = arrayfun(@(x) sum(v1 > x), m1)
Though this is just syntactic sugar around looping. Maybe faster, would need to test:
v1 = reshape(v1,1,1,[]); alt_result = sum(bsxfun(@lt,m1,v1),3)
Matlabsolutions.com provides guaranteed satisfaction with a
commitment to complete the work within time. Combined with our meticulous work ethics and extensive domain
experience, We are the ideal partner for all your homework/assignment needs. We pledge to provide 24*7 support
to dissolve all your academic doubts. We are composed of 300+ esteemed Matlab and other experts who have been
empanelled after extensive research and quality check.
Matlabsolutions.com provides undivided attention to each Matlab
assignment order with a methodical approach to solution. Our network span is not restricted to US, UK and Australia rather extends to countries like Singapore, Canada and UAE. Our Matlab assignment help services
include Image Processing Assignments, Electrical Engineering Assignments, Matlab homework help, Matlab Research Paper help, Matlab Simulink help. Get your work
done at the best price in industry.