setelah m-file terbuka ketikkan sebagai berikut:
function ll=luaslingkaran(r);
ll=pi*r.^2;
end
setelah memasukkan fungsi di atas, simpan data dengan nama luaslingkaran.m.(tekan F5 untuk meng eksekusi) setelah tersimpan maka buka command window dan ketikkan sbb:
ll=luaslingkaran(7)
dan akan diperleh hasil:
ll=154
silahkan mencoba!
This Blog science home made to help other understood about science and as gift imformation place.
Selasa, Juni 16, 2015
Selasa, Juni 02, 2015
polyval Matlab
Contoh polyval…
Examples This example involves fitting the error function, erf(x), by a polynomial in x.
This is a risky project because erf(x) is a bounded function, while polynomials are unbounded, so the fit might not be very good. First generate a vector of x points, equally spaced in the interval ; then evaluate erf(x) at those points.
x = (0: 0.1: 2.5)'; y = erf(x);
The coefficients in the approximating polynomial of degree 6 are
p = polyfit(x,y,6) p = 0.0084 -0.0983 0.4217 -0.7435 0.1471 1.1064 0.0004
There are seven coefficients and the polynomial is To see how good the fit is, evaluate the polynomial at the data points with
f = polyval(p,x);
A table showing the data, fit, and error is table = [x y f y-f] table = 0 0 0.0004 -0.0004 0.1000 0.1125 0.1119 0.0006 0.2000 0.2227 0.2223 0.0004 0.3000 0.3286 0.3287 -0.0001 0.4000 0.4284 0.4288 -0.0004 ... 2.1000 0.9970 0.9969 0.0001 2.2000 0.9981 0.9982 -0.0001 2.3000 0.9989 0.9991 -0.0003 2.4000 0.9993 0.9995 -0.0002 2.5000 0.9996 0.9994 0.0002
So, on this interval, the fit is good to between three and four digits. Beyond this interval the graph shows that the polynomial behavior takes over and the approximation quickly deteriorates.
x = (0: 0.1: 5)'; y = erf(x); f = polyval(p,x); plot(x,y,'o',x,f,'-') axis([0 5 0 2])
Algorithm The polyfit M-file forms the Vandermonde matrix, , whose elements are powers of . It then uses the backslash operator, \, to solve the least squares problem You can modify the M-file to use other functions of as the basis functions.
Examples This example involves fitting the error function, erf(x), by a polynomial in x.
This is a risky project because erf(x) is a bounded function, while polynomials are unbounded, so the fit might not be very good. First generate a vector of x points, equally spaced in the interval ; then evaluate erf(x) at those points.
x = (0: 0.1: 2.5)'; y = erf(x);
The coefficients in the approximating polynomial of degree 6 are
p = polyfit(x,y,6) p = 0.0084 -0.0983 0.4217 -0.7435 0.1471 1.1064 0.0004
There are seven coefficients and the polynomial is To see how good the fit is, evaluate the polynomial at the data points with
f = polyval(p,x);
A table showing the data, fit, and error is table = [x y f y-f] table = 0 0 0.0004 -0.0004 0.1000 0.1125 0.1119 0.0006 0.2000 0.2227 0.2223 0.0004 0.3000 0.3286 0.3287 -0.0001 0.4000 0.4284 0.4288 -0.0004 ... 2.1000 0.9970 0.9969 0.0001 2.2000 0.9981 0.9982 -0.0001 2.3000 0.9989 0.9991 -0.0003 2.4000 0.9993 0.9995 -0.0002 2.5000 0.9996 0.9994 0.0002
So, on this interval, the fit is good to between three and four digits. Beyond this interval the graph shows that the polynomial behavior takes over and the approximation quickly deteriorates.
x = (0: 0.1: 5)'; y = erf(x); f = polyval(p,x); plot(x,y,'o',x,f,'-') axis([0 5 0 2])
Algorithm The polyfit M-file forms the Vandermonde matrix, , whose elements are powers of . It then uses the backslash operator, \, to solve the least squares problem You can modify the M-file to use other functions of as the basis functions.
Sabtu, Mei 30, 2015
Sajadah Nabi di Langit Melbourne
Kutipan dari buku sajadah Nabi di
Langit Melbourne
Saat mondok di pompes MIftahul Jannah,
Ust. Pernah mengisahkan cerrita yang membuat dadaku tertuusuk, getir dan
menghantamku bertubi-tubi. Apa yng kamu lakkukan jika orang yang kamu cintai
diolok-olok pertanyaan ang tidak akan terjawab benar, kecuali oleh mereka yg
memahami hakikat cinta.
Bukankah Nabi SAW ketika hijrah ke
Thaifmendapat perlakuan yang memilukan? Perlakuan orang-orang Thaif yang tidak
bisa ditolerir. Mereka tak ubahnya keledai dungu, tuli saat kebenaran diserukan.
Bahkan, batu-batu dan kotoran beterbangan melepari Nabi saw. Dengan ganasnya.
Pernakah mendengar kisah bahwa di
sebuah pasar Madinah, telah lama dudu seorang Yahudi sambil mengemis, sedangkan
matanya tak dapat melihat alias buta.orang itu sangat membenci islam. Ia selalu
engiklankan sang pelopor penyebaran Islam, Muhammad dengan kata-kata kotor
pemicu radikalisme Ummat Islam yang mendengarnya.perkataan yang memerahkan
telinga, membakar wajah dan mencabik nurani. Setiap orang yang mndekatinya akan
diberikan nasihat bahwa jiwa Muhammad saw. Adalah orang gila, pendusta dan ahli
nujum.
Nai saw. Setiap hatri tahu ucapan-ucpan
tk berarti it uterus menyebar. Sambil membawa makanan setiap pagi beliau
mendatangi dan menyuakan ke dalam mulunya. Sampai kapan? Ampai beliau wafat.
Abu Bakar diberi tahu Aisya jika Nabi
saw. Melakukan perbuatan itusetiap hari hingga Abu Bakar ingin menirunya.ketika
tangan Abu Bakar menyuapkan makanan ke mulutnya, si Yhudi protes. Iaa tahu bahw
orang yang selalu memberinya makan bukanah dirinya. Ia marah dan mebentak.
Orang yang biasa mendatanginya, sebelum menyuap makanan, terleih dahulu
dihaluskan dengan mulutna setelah itu dia berikan dengan mulutnya sendiri,
orang itu begitu halus budinya.
Abu Bakar tidak mampu menahan tangis
mendayu, kemudianmenceritakan bahwa orang mulia itu telah tada. Ia adalah
Muhammad, Rasulullah saw.
Pengemis kaget, seperti bayi yang
kehilangan ibunya, merengek, menangis. Ia selalu menghina dan menfitnahnya,
tapi nabi tidak pernah merasa marah sedkit pun. Ia begitu mulia.
Langganan:
Postingan (Atom)