dengan sourcenya:
function test_sin_sin clc; x = linspace(0, 2*pi ); cut(2); cut(15); cut(30); function cut(a) y = 'sin('; for i=1:a, y = strcat(y,'sin('); end y = strcat(y, 'x)'); for i=1:a, y = strcat(y, ')'); end y = eval(y); plot(x, y); hold on ; end endAdapun untuk python adalah
dengan source-nya
# -*- coding: utf-8 -*- """ Created on Thu Dec 19 15:22:44 2013 @author: fajar """ x = linspace(-pi,pi, 1000); def test(a): aa = 'sin(' for i in range(a): aa += 'sin(' aa += 'x)' for i in range(a): aa+= ')' yy = eval(aa); plot(x, yy); test(90)
No comments:
Post a Comment