忍者ブログ
Yaleで、遊んで学ぶ日々。

Yaleで、遊んで学ぶ日々。

囲碁、ときどきプログラミング、ところにより経済。
×

[PR]上記の広告は3ヶ月以上新規記事投稿のないブログに表示されています。新しい記事を書く事で広告が消えます。

Matlabプログラミングの問題が出されて、答えを書くとその長さに応じて得点が入る。短いほど高得点らしい。
http://www.mathworks.com/matlabcentral/cody/


今日はこれを考えてみる(ソース)。

INSTRUCTIONS

This is a multi-dimensional variant of the normal multiplication table used to teach elementary students multiplication. In this variant, we are going to produce a table that multiplies the divisors 1 to n (input) agains itself in d dimensions.

Note: Inputting d = 0 should return the number 1 and d = 1 should return a column vector with the elements 1 to n.

Example:

Input:

n = 3;
d = 3;

Output:

tt(:,:,1) = [ 1  2  3
              2  4  6
              3  6  9  ];
tt(:,:,2) = [ 2  4  6
              4  8  12
              6  12 18 ];
tt(:,:,3) = [ 3  6  9
              6  12 18
              9  18 27 ];
PR

Source --> Walking Randomly

遊び心を忘れずに生きていきたい。


hi.png














Code:

x = linspace(-3,3,50);
y = linspace(-5,5,50);
[X Y]=meshgrid(x,y);
Z = exp(-X.^2-Y.^2/2).*cos(4*X) + exp(-3*((X+0.5).^2+Y.^2/2));
Z(Z>0.001)=0.001;
Z(Z<-0.001)=-0.001;
surf(X,Y,Z);
colormap(flipud(cool))
view([1 -1.5 2])
 
Calender
02 2024/03 04
S M T W T F S
1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
31
Search in This Blog
Latest Comments
[03/30 川内のばば山田]
[03/30 川内のばば山田]
[08/06 Aterarie]
[07/05 Agazoger]
[07/01 Thomaskina]
Oldest Posts
Latest Trackbacks
フリーエリア

Barcode
Access Analysis
Powerd by NINJAブログ / Designed by SUSH
Copyright © Yaleで、遊んで学ぶ日々。 All Rights Reserved.
忍者ブログ [PR]