MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Solution 235459

Submitted on 25 Apr 2013 by Richard Zapor

Correct

274Size
`This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.`

Test Suite

Test
Code Input and Output
1
Pass

```tic
w=50+randi(100,1) % case random 1 15
pymax=randi(50,1)
polycell={[0 0 10 pymax 20 0]}; % case 1 15
d=Thin_Ice(w,polycell)
assert(abs(d-(w-pymax))<.01)
toc
```
```w =
142
pymax =
32
Min Thin Ice 110.0000
d =
110
Elapsed time is 0.011334 seconds.
```
2
Pass

```%%
tic
w=110+randi(100,1); % case random 2
w
pymax1=randi(30,1)
pymax2=randi(10,1)
pymax3=randi(10,1)
polycell={[0 0 10 pymax1 pymax3 0] [-pymax2 30+pymax2 20+pymax1 30+pymax2 pymax1 40+pymax3]}; % case random
d=Thin_Ice(w,polycell)
assert(abs(d-(w-pymax1-(40+pymax3-(30+pymax2))))<.01)
toc
```
```w =
120
pymax1 =
9
pymax2 =
6
pymax3 =
10
Min Thin Ice 97.0000
d =
97
Elapsed time is 0.006939 seconds.
```
3
Pass

```%%
tic
w=100; % case 1 15
polycell={[0 0 10 85 20 0]}; % case 1 15
d=Thin_Ice(w,polycell);
assert(abs(d-15)<.01)
toc
```
```Min Thin Ice 15.0000
Elapsed time is 0.000910 seconds.
```
4
Pass

```%%
tic
w=10; %case 2 5
polycell={[-2 0 -2 2 2 2 2 0] [-2 5 -2 8 2 8 2 5]};
d=Thin_Ice(w,polycell);
assert(abs(d-5)<.01)
toc
```
```Min Thin Ice 5.0000
Elapsed time is 0.001603 seconds.
```
5
Pass

```%%
tic
w=3618;% case 3 3598
polycell={[550 201 546 211 555 221 564 211 560 201]};
d=Thin_Ice(w,polycell);
assert(abs(d-3598)<.01)
toc
```
```Min Thin Ice 3598.0000
Elapsed time is 0.000269 seconds.
```
6
Pass

```%%
tic
w=3618;% case 4 3593.57
polycell={[550 201 546 211 555 221 564 211 560 201]...
[570 211 566 221 575 231 584 221 580 211]};
d=Thin_Ice(w,polycell);
assert(abs(d-3593.57)<.01)
toc
```
```Min Thin Ice 3593.5709
Elapsed time is 0.001215 seconds.
```
7
Pass

```%%
tic
w=3618; % case 5 3598
polycell={[550 201 546 211 555 221 564 211 560 201]...
[1570 211 1566 221 1575 231 1584 221 1580 211]};
d=Thin_Ice(w,polycell);
assert(abs(d-3598)<.01)
toc
```
```Min Thin Ice 3598.0000
Elapsed time is 0.001077 seconds.
```
8
Pass

```%%
tic
w=10; %case 6 5
polycell={[-2 0 -2 2 2 2 2 0]...
[-10 5 -10 8 10 8 10 5]};
d=Thin_Ice(w,polycell);
assert(abs(d-5)<.01)
toc
```
```Min Thin Ice 5.0000
Elapsed time is 0.000962 seconds.
```
9
Pass

```%%
tic
w=10000; %case 7 1615.15
polycell={[-912000 8801 -912000 8881 -911001 8881 -911001 8801]...
[-910000 9001 -910000 9087 -909001 9087 -909001 9001]...
[ -993000 701 -993000 789 -992001 789 -992001 701]...
[ -960000 4001 -960000 4082 -959001 4082 -959001 4001]...
[ -984000 1601 -984000 1687 -983001 1687 -983001 1601]...
[ -980000 2001 -980000 2089 -979001 2089 -979001 2001]...
[ -942000 5801 -942000 5883 -941001 5883 -941001 5801]...
[ -909000 9101 -909000 9185 -908001 9185 -908001 9101]...
[ -967000 3301 -967000 3387 -966001 3387 -966001 3301]...
[ -947000 5301 -947000 5382 -946001 5382 -946001 5301]...
[ -908000 9201 -908000 9282 -907001 9282 -907001 9201]...
[ -903000 9701 -903000 9781 -902001 9781 -902001 9701]...
[ -951000 4901 -951000 4986 -950001 4986 -950001 4901]...
[ -963000 3701 -963000 3788 -962001 3788 -962001 3701]...
[ -973000 2701 -973000 2783 -972001 2783 -972001 2701]...
[ -975000 2501 -975000 2584 -974001 2584 -974001 2501]...
[ -994000 601 -994000 680 -993001 680 -993001 601]...
[ -1000000 1 -1000000 86 -999001 86 -999001 1]...
[ -999000 101 -999000 187 -998001 187 -998001 101]...
[ -954000 4601 -954000 4686 -953001 4686 -953001 4601]...
[ -930000 7001 -930000 7082 -929001 7082 -929001 7001]...
[ -974000 2601 -974000 2680 -973001 2680 -973001 2601]...
[ -926000 7401 -926000 7488 -925001 7488 -925001 7401]...
[ -945000 5501 -945000 5583 -944001 5583 -944001 5501]...
[ -956000 4401 -956000 4480 -955001 4480 -955001 4401]...
[ -971000 2901 -971000 2987 -970001 2987 -970001 2901]...
[ -933000 6701 -933000 6789 -932001 6789 -932001 6701]...
[ -976000 2401 -976000 2482 -975001 2482 -975001 2401]...
[ -970000 3001 -970000 3086 -969001 3086 -969001 3001]...
[ -981000 1901 -981000 1989 -980001 1989 -980001 1901]...
[ -955000 4501 -955000 4580 -954001 4580 -954001 4501]...
[ -950000 5001 -950000 5088 -949001 5088 -949001 5001]...
[ -906000 9401 -906000 9481 -905001 9481 -905001 9401]...
[ -927000 7301 -927000 7386 -926001 7386 -926001 7301]...
[ -911000 8901 -911000 8987 -910001 8987 -910001 8901]...
[ -928000 7201 -928000 7282 -927001 7282 -927001 7201]...
[ -996000 401 -996000 480 -995001 480 -995001 401]...
[ -966000 3401 -966000 3483 -965001 3483 -965001 3401]...
[ -925000 7501 -925000 7588 -924001 7588 -924001 7501]...
[ -905000 9501 -905000 9587 -904001 9587 -904001 9501]...
[ -943000 5701 -943000 5785 -942001 5785 -942001 5701]...
[ -990000 1001 -990000 1087 -989001 1087 -989001 1001]...
[ -948000 5201 -948000 5288 -947001 5288 -947001 5201]...
[ -968000 3201 -968000 3281 -967001 3281 -967001 3201]...
[ -989000 1101 -989000 1180 -988001 1180 -988001 1101]...
[ -935000 6501 -935000 6587 -934001 6587 -934001 6501]...
[ -936000 6401 -936000 6484 -935001 6484 -935001 6401]...
[ -998000 201 -998000 283 -997001 283 -997001 201]...
[ -932000 6801 -932000 6886 -931001 6886 -931001 6801]...
[ -918000 8201 -918000 8282 -917001 8282 -917001 8201]...
[ -916000 8401 -916000 8486 -915001 8486 -915001 8401]...
[ -952000 4801 -952000 4880 -951001 4880 -951001 4801]...
[ -992000 801 -992000 886 -991001 886 -991001 801]...
[ -913000 8701 -913000 8786 -912001 8786 -912001 8701]...
[ -901000 9901 -901000 9989 -900001 9989 -900001 9901]...
[ -962000 3801 -962000 3887 -961001 3887 -961001 3801]...
[ -902000 9801 -902000 9884 -901001 9884 -901001 9801]...
[ -917000 8301 -917000 8384 -916001 8384 -916001 8301]...
[ -985000 1501 -985000 1583 -984001 1583 -984001 1501]...
[ -979000 2101 -979000 2188 -978001 2188 -978001 2101]...
[ -940000 6001 -940000 6088 -939001 6088 -939001 6001]...
[ -988000 1201 -988000 1282 -987001 1282 -987001 1201]...
[ -904000 9601 -904000 9687 -903001 9687 -903001 9601]...
[ -922000 7801 -922000 7885 -921001 7885 -921001 7801]...
[ -929000 7101 -929000 7188 -928001 7188 -928001 7101]...
[ -907000 9301 -907000 9389 -906001 9389 -906001 9301]...
[ -997000 301 -997000 381 -996001 381 -996001 301]...
[ -939000 6101 -939000 6181 -938001 6181 -938001 6101]...
[ -983000 1701 -983000 1787 -982001 1787 -982001 1701]...
[ -978000 2201 -978000 2285 -977001 2285 -977001 2201]...
[ -944000 5601 -944000 5686 -943001 5686 -943001 5601]...
[ -987000 1301 -987000 1382 -986001 1382 -986001 1301]...
[ -986000 1401 -986000 1484 -985001 1484 -985001 1401]...
[ -982000 1801 -982000 1887 -981001 1887 -981001 1801]...
[ -934000 6601 -934000 6687 -933001 6687 -933001 6601]...
[ -972000 2801 -972000 2884 -971001 2884 -971001 2801]...
[ -938000 6201 -938000 6282 -937001 6282 -937001 6201]...
[ -964000 3601 -964000 3685 -963001 3685 -963001 3601]...
[ -915000 8501 -915000 8586 -914001 8586 -914001 8501]...
[ -937000 6301 -937000 6383 -936001 6383 -936001 6301]...
[ -919000 8101 -919000 8187 -918001 8187 -918001 8101]...
[ -949000 5101 -949000 5186 -948001 5186 -948001 5101]...
[ -953000 4701 -953000 4782 -952001 4782 -952001 4701]...
[ -959000 4101 -959000 4188 -958001 4188 -958001 4101]...
[ -961000 3901 -961000 3988 -960001 3988 -960001 3901]...
[ -920000 8001 -920000 8088 -919001 8088 -919001 8001]...
[ -931000 6901 -931000 6981 -930001 6981 -930001 6901]...
[ -914000 8601 -914000 8686 -913001 8686 -913001 8601]...
[ -924000 7601 -924000 7687 -923001 7687 -923001 7601]...
[ -923000 7701 -923000 7789 -922001 7789 -922001 7701]...
[ -965000 3501 -965000 3584 -964001 3584 -964001 3501]...
[ -958000 4201 -958000 4280 -957001 4280 -957001 4201]...
[ -991000 901 -991000 989 -990001 989 -990001 901]...
[ -957000 4301 -957000 4383 -956001 4383 -956001 4301]...
[ -969000 3101 -969000 3187 -968001 3187 -968001 3101]...
[ -977000 2301 -977000 2388 -976001 2388 -976001 2301]...
[ -946000 5401 -946000 5484 -945001 5484 -945001 5401]...
[ -995000 501 -995000 589 -994001 589 -994001 501]...
[ -921000 7901 -921000 7983 -920001 7983 -920001 7901]...
[ -941000 5901 -941000 5981 -940001 5981 -940001 5901]};
d=Thin_Ice(w,polycell);
assert(abs(d-1615.15)<.01)
toc
```
```Min Thin Ice 1615.1534
Elapsed time is 2.880048 seconds.
```
10
Pass

```%%
tic
w=11000; % case 8 1536.76
polycell={[-918919 8101 -918919 8197 -917920 8197 -917920 8101]...
[ -965966 3401 -965966 3502 -964967 3502 -964967 3401]...
[ -989990 1001 -989990 1126 -988991 1126 -988991 1001]...
[ -940941 5901 -940941 5984 -939942 5984 -939942 5901]...
[ -975976 2401 -975976 2489 -974977 2489 -974977 2401]...
[ -968969 3101 -968969 3207 -967970 3207 -967970 3101]...
[ -957958 4201 -957958 4296 -956959 4296 -956959 4201]...
[ -970971 2901 -970971 3021 -969972 3021 -969972 2901]...
[ -927928 7201 -927928 7325 -926929 7325 -926929 7201]...
[ -956957 4301 -956957 4382 -955958 4382 -955958 4301]...
[ -947948 5201 -947948 5296 -946949 5296 -946949 5201]...
[ -988989 1101 -988989 1225 -987990 1225 -987990 1101]...
[ -915916 8401 -915916 8497 -914917 8497 -914917 8401]...
[ -907908 9201 -907908 9294 -906909 9294 -906909 9201]...
[ -997998 201 -997998 289 -996999 289 -996999 201]...
[ -911912 8801 -911912 8908 -910913 8908 -910913 8801]...
[ -972973 2701 -972973 2826 -971974 2826 -971974 2701]...
[ -952953 4701 -952953 4817 -951954 4817 -951954 4701]...
[ -980981 1901 -980981 2010 -979982 2010 -979982 1901]...
[ -932933 6701 -932933 6783 -931934 6783 -931934 6701]...
[ -964965 3501 -964965 3609 -963966 3609 -963966 3501]...
[ -978979 2101 -978979 2194 -977980 2194 -977980 2101]...
[ -925926 7401 -925926 7505 -924927 7505 -924927 7401]...
[ -973974 2601 -973974 2703 -972975 2703 -972975 2601]...
[ -990991 901 -990991 1002 -989992 1002 -989992 901]...
[ -966967 3301 -966967 3389 -965968 3389 -965968 3301]...
[ -977978 2201 -977978 2297 -976979 2297 -976979 2201]...
[ -945946 5401 -945946 5505 -944947 5505 -944947 5401]...
[ -938939 6101 -938939 6229 -937940 6229 -937940 6101]...
[ -909910 9001 -909910 9080 -908911 9080 -908911 9001]...
[ -924925 7501 -924925 7629 -923926 7629 -923926 7501]...
[ -900901 9901 -900901 10022 -899902 10022 -899902 9901]...
[ -954955 4501 -954955 4605 -953956 4605 -953956 4501]...
[ -926927 7301 -926927 7382 -925928 7382 -925928 7301]...
[ -905906 9401 -905906 9507 -904907 9507 -904907 9401]...
[ -981982 1801 -981982 1892 -980983 1892 -980983 1801]...
[ -1000000 1 -1000000 102 -999001 102 -999001 1]...
[ -930931 6901 -930931 7023 -929932 7023 -929932 6901]...
[ -959960 4001 -959960 4123 -958961 4123 -958961 4001]...
[ -917918 8201 -917918 8319 -916919 8319 -916919 8201]...
[ -942943 5701 -942943 5794 -941944 5794 -941944 5701]...
[ -941942 5801 -941942 5880 -940943 5880 -940943 5801]...
[ -901902 9801 -901902 9922 -900903 9922 -900903 9801]...
[ -995996 401 -995996 510 -994997 510 -994997 401]...
[ -903904 9601 -903904 9683 -902905 9683 -902905 9601]...
[ -914915 8501 -914915 8623 -913916 8623 -913916 8501]...
[ -998999 101 -998999 192 -998000 192 -998000 101]...
[ -921922 7801 -921922 7885 -920923 7885 -920923 7801]...
[ -969970 3001 -969970 3116 -968971 3116 -968971 3001]...
[ -912913 8701 -912913 8812 -911914 8812 -911914 8701]...
[ -987988 1201 -987988 1328 -986989 1328 -986989 1201]...
[ -902903 9701 -902903 9827 -901904 9827 -901904 9701]...
[ -982983 1701 -982983 1815 -981984 1815 -981984 1701]...
[ -920921 7901 -920921 8002 -919922 8002 -919922 7901]...
[ -971972 2801 -971972 2891 -970973 2891 -970973 2801]...
[ -979980 2001 -979980 2107 -978981 2107 -978981 2001]...
[ -939940 6001 -939940 6085 -938941 6085 -938941 6001]...
[ -906907 9301 -906907 9416 -905908 9416 -905908 9301]...
[ -951952 4801 -951952 4889 -950953 4889 -950953 4801]...
[ -946947 5301 -946947 5404 -945948 5404 -945948 5301]...
[ -961962 3801 -961962 3905 -960963 3905 -960963 3801]...
[ -916917 8301 -916917 8404 -915918 8404 -915918 8301]...
[ -983984 1601 -983984 1680 -982985 1680 -982985 1601]...
[ -937938 6201 -937938 6290 -936939 6290 -936939 6201]...
[ -963964 3601 -963964 3693 -962965 3693 -962965 3601]...
[ -922923 7701 -922923 7814 -921924 7814 -921924 7701]...
[ -962963 3701 -962963 3816 -961964 3816 -961964 3701]...
[ -931932 6801 -931932 6890 -930933 6890 -930933 6801]...
[ -960961 3901 -960961 4021 -959962 4021 -959962 3901]...
[ -984985 1501 -984985 1624 -983986 1624 -983986 1501]...
[ -992993 701 -992993 810 -991994 810 -991994 701]...
[ -986987 1301 -986987 1390 -985988 1390 -985988 1301]...
[ -955956 4401 -955956 4504 -954957 4504 -954957 4401]...
[ -919920 8001 -919920 8086 -918921 8086 -918921 8001]...
[ -944945 5501 -944945 5613 -943946 5613 -943946 5501]...
[ -943944 5601 -943944 5718 -942945 5718 -942945 5601]...
[ -974975 2501 -974975 2590 -973976 2590 -973976 2501]...
[ -913914 8601 -913914 8696 -912915 8696 -912915 8601]...
[ -923924 7601 -923924 7692 -922925 7692 -922925 7601]...
[ -985986 1401 -985986 1491 -984987 1491 -984987 1401]...
[ -996997 301 -996997 387 -995998 387 -995998 301]...
[ -934935 6501 -934935 6623 -933936 6623 -933936 6501]...
[ -953954 4601 -953954 4720 -952955 4720 -952955 4601]...
[ -933934 6601 -933934 6702 -932935 6702 -932935 6601]...
[ -991992 801 -991992 893 -990993 893 -990993 801]...
[ -910911 8901 -910911 9000 -909912 9000 -909912 8901]...
[ -967968 3201 -967968 3298 -966969 3298 -966969 3201]...
[ -908909 9101 -908909 9219 -907910 9219 -907910 9101]...
[ -949950 5001 -949950 5113 -948951 5113 -948951 5001]...
[ -993994 601 -993994 717 -992995 717 -992995 601]...
[ -948949 5101 -948949 5199 -947950 5199 -947950 5101]...
[ -950951 4901 -950951 5014 -949952 5014 -949952 4901]...
[ -958959 4101 -958959 4218 -957960 4218 -957960 4101]...
[ -928929 7101 -928929 7196 -927930 7196 -927930 7101]...
[ -904905 9501 -904905 9604 -903906 9604 -903906 9501]...
[ -976977 2301 -976977 2422 -975978 2422 -975978 2301]...
[ -929930 7001 -929930 7122 -928931 7122 -928931 7001]...
[ -994995 501 -994995 607 -993996 607 -993996 501]...
[ -935936 6401 -935936 6515 -934937 6515 -934937 6401]...
[ -936937 6301 -936937 6415 -935938 6415 -935938 6301]};
d=Thin_Ice(w,polycell);
assert(abs(d-1536.76)<.01)
toc
```
```Min Thin Ice 1536.7557
Elapsed time is 2.909344 seconds.
```
11
Pass

```%%
tic
w=120;%case 9 35.62
polycell={[0 10 0 90 50 50 100 90 100 10]...
[0 110 100 110 50 70]};
d=Thin_Ice(w,polycell);
assert(abs(d-35.6174)<.01)
toc
```
```Min Thin Ice 35.6174
Elapsed time is 0.000952 seconds.
```