Cody

# Problem 2029. Convert vector datasets to plot with imagesc instead of scatter

Solution 363200

Submitted on 3 Dec 2013 by Alfonso Nieto-Castanon
• Size: 61
• This is the leading solution.
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

This solution is outdated. To rescore this solution, sign in.

### Test Suite

Test Status Code Input and Output
1   Pass
%% rng('default'); b=[6,9]; x=rand(3333,1)*100*b(1)+1500; y=rand(3333,1)*100*b(2)+50000; d=sind(sqrt(x.^2+y.^2))./sqrt(x.^2+y.^2); G=binit(x,y,d,b); chk1=sum(sum(G~=0)); chk2=roundn(mean(abs(G(G~=0))),-8); assert(isequal(chk1,2809)) assert(isequal(chk2,1.2680e-05))

2   Pass
%% rng('default'); b=[25,12.5]; x=rand(5,1)*10*b(1)-200; y=rand(5,1)*10*b(2)-50; d=roundn(2*x+3*y-x.*y+30,1); G=binit(x,y,d,b); oide=[ 0 0 0 0 0 0 60 0 0 0 0 0 0 0 0 440 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2840 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3120 0 -1680]; assert(isequal(G,oide))

3   Pass
%% rng('default'); b=[2,4]; x=rand(1000,1)*25*b(1)+1000; y=rand(1000,1)*25*b(2)+200; d=roundn(x-y-750,1); G=binit(x,y,d,b) oide=[50 50 50 50 60 60 0 60 0 0 70 70 70 70 80 80 80 0 80 90 0 0 90 100 0 40 50 50 50 50 50 60 0 0 60 0 70 70 70 70 70 80 80 80 0 80 90 0 0 90 40 0 40 50 50 50 0 60 60 0 60 60 60 70 70 0 70 80 80 80 0 80 90 0 0 0 40 40 40 40 50 0 50 50 50 60 60 60 60 70 0 70 70 70 80 80 80 80 80 80 0 30 40 40 0 50 40 0 50 0 50 50 60 60 0 60 60 60 0 70 70 80 80 0 80 0 30 30 0 40 40 40 40 40 50 50 50 50 50 60 60 60 60 60 70 70 0 70 80 80 30 30 30 30 30 30 40 40 40 40 40 0 0 50 0 0 0 60 0 60 0 70 0 70 70 20 20 30 30 30 0 30 40 0 40 40 0 40 50 50 0 50 0 60 0 60 0 70 0 70 20 20 20 20 20 0 30 30 0 40 40 0 0 40 50 50 50 50 50 50 60 0 60 60 0 10 20 20 20 20 20 30 30 0 30 0 40 40 40 40 40 40 50 50 0 50 60 60 60 60 10 10 10 20 20 20 20 20 30 30 30 0 30 40 30 40 40 0 50 50 50 0 0 60 50 0 10 10 10 10 20 0 0 20 0 20 0 30 0 0 40 40 40 40 40 0 50 50 50 0 0 0 0 10 0 10 10 20 0 20 20 20 20 30 30 30 30 0 40 40 0 40 40 50 50 0 0 0 0 0 10 10 10 10 10 20 20 0 20 20 0 30 30 30 0 40 40 40 40 0 -10 -10 0 0 0 0 0 10 10 10 10 20 10 20 20 20 20 30 30 30 30 30 0 40 40 -10 -10 -10 0 0 0 0 0 10 10 10 10 0 0 20 20 20 20 30 0 30 30 0 40 0 0 0 -10 -10 -10 -10 0 0 0 0 0 10 10 10 10 20 20 20 20 20 0 30 30 30 30 -20 -20 -10 -10 -10 -10 0 0 0 0 0 0 0 10 10 10 0 10 20 20 0 20 20 30 0 0 -20 -20 -20 -20 -10 -10 0 -10 0 0 0 0 0 0 10 10 10 10 10 0 0 20 20 30 0 -30 -20 -20 -20 0 -10 -10 -10 -10 0 -10 0 0 0 0 10 0 10 10 10 0 20 20 20 0 -30 -30 0 -20 -20 -20 -20 -10 -10 -10 -10 -10 -10 0 0 0 0 10 10 10 10 10 10 20 0 0 -30 -30 -30 -30 -20 -20 -20 0 0 -10 -10 -10 -10 0 0 0 0 0 0 10 0 10 0 -40 -40 -40 -30 -30 -30 -30 -30 -20 -20 -20 -20 0 0 -10 -10 -10 0 0 0 0 0 0 0 10 -40 -40 0 -40 -30 -30 -30 0 -30 0 -20 -20 0 -20 -10 -10 -10 -10 -10 -10 0 0 0 0 0 -50 -40 0 -40 -40 0 -30 0 -30 -30 -30 -20 -20 -20 -20 -20 -10 -10 -10 -10 0 0 0 0 0 ]; assert(isequal(G,oide))

G = Columns 1 through 16 50 50 50 50 60 60 0 60 0 0 70 70 70 70 80 80 40 50 50 50 50 50 60 0 0 60 0 70 70 70 70 70 40 0 40 50 50 50 0 60 60 0 60 60 60 70 70 0 0 40 40 40 40 50 0 50 50 50 60 60 60 60 70 0 0 30 40 40 0 50 40 0 50 0 50 50 60 60 0 60 0 30 30 0 40 40 40 40 40 50 50 50 50 50 60 60 30 30 30 30 30 30 40 40 40 40 40 0 0 50 0 0 20 20 30 30 30 0 30 40 0 40 40 0 40 50 50 0 20 20 20 20 20 0 30 30 0 40 40 0 0 40 50 50 10 20 20 20 20 20 30 30 0 30 0 40 40 40 40 40 10 10 10 20 20 20 20 20 30 30 30 0 30 40 30 40 0 10 10 10 10 20 0 0 20 0 20 0 30 0 0 40 0 0 0 10 0 10 10 20 0 20 20 20 20 30 30 30 0 0 0 0 0 10 10 10 10 10 20 20 0 20 20 0 -10 -10 0 0 0 0 0 10 10 10 10 20 10 20 20 20 -10 -10 -10 0 0 0 0 0 10 10 10 10 0 0 20 20 0 0 -10 -10 -10 -10 0 0 0 0 0 10 10 10 10 20 -20 -20 -10 -10 -10 -10 0 0 0 0 0 0 0 10 10 10 0 -20 -20 -20 -20 -10 -10 0 -10 0 0 0 0 0 0 10 0 -30 -20 -20 -20 0 -10 -10 -10 -10 0 -10 0 0 0 0 0 -30 -30 0 -20 -20 -20 -20 -10 -10 -10 -10 -10 -10 0 0 0 0 -30 -30 -30 -30 -20 -20 -20 0 0 -10 -10 -10 -10 0 -40 -40 -40 -30 -30 -30 -30 -30 -20 -20 -20 -20 0 0 -10 -10 -40 -40 0 -40 -30 -30 -30 0 -30 0 -20 -20 0 -20 -10 -10 -50 -40 0 -40 -40 0 -30 0 -30 -30 -30 -20 -20 -20 -20 -20 Columns 17 through 25 80 0 80 90 0 0 90 100 0 80 80 80 0 80 90 0 0 90 70 80 80 80 0 80 90 0 0 70 70 70 80 80 80 80 80 80 60 60 0 70 70 80 80 0 80 60 60 60 70 70 0 70 80 80 0 60 0 60 0 70 0 70 70 50 0 60 0 60 0 70 0 70 50 50 50 50 60 0 60 60 0 40 50 50 0 50 60 60 60 60 40 0 50 50 50 0 0 60 50 40 40 40 40 0 50 50 50 0 30 0 40 40 0 40 40 50 50 30 30 30 0 40 40 40 40 0 20 30 30 30 30 30 0 40 40 20 20 30 0 30 30 0 40 0 20 20 20 20 0 30 30 30 30 0 10 20 20 0 20 20 30 0 10 10 10 10 0 0 20 20 30 10 0 10 10 10 0 20 20 20 0 0 10 10 10 10 10 10 20 0 0 0 0 0 10 0 10 0 -10 0 0 0 0 0 0 0 10 -10 -10 -10 -10 0 0 0 0 0 -10 -10 -10 -10 0 0 0 0 0

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!