Your SlideShare is downloading. ×
Matlab simulation project
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Matlab simulation project

77

Published on

Published in: Education
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
77
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
4
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. MATLAB SIMULATION (SAMPLE ASSIGNMENT) Our online Tutors are available 24*7 to provide Help with Help with Matlab Simulation Homework/Assignment or a long term Graduate/Undergraduate Help with Matlab Simulation Project. Our Tutors being experienced and proficient in Help with Matlab Simulation ensure to provide high quality Help with Matlab Simulation Homework Help. Upload your Help with Matlab Simulation Assignment at ‘Submit Your Assignment’ button or email it to . You can use our ‘Live Chat’ option to schedule an Online Tutoring session with our Help with Matlab Simulation Tutors. Monte Carlo Method This sample assignment shows Calculating pi using Monte Carlo Method MonteCarlo.m % To calculate the value of pi using Monte Carlo Method %------------------------------------------------------------------------- % Code written by : Siva Srinivas Kolukula | % Senior Research Fellow | % Structural Mechanics Laboratory | % Indira Gandhi Center for Atomic Research | % India | % E-mail : allwayzitzme@gmail.com | % http://sites.google.com/site/kolukulasivasrinivas/ | %------------------------------------------------------------------------- clear all ;clc ; % Radius of the Circle R = 1 ; shg clf reset set(gcf,'color','w','menubar','none','numbertitle','off','name','Monte Carlo Method ') ; x = [0.; 0.]; h = plot(x(1),x(2),'.'); set(h,'markersize',1.5,'erasemode','none'); title('Calculation of pi using Monte Carlo Method','Color','r','fontweight','bold') ; axis([-R R -R R]) ; axis equal ; axis off ; % Stop and close toggle button stop = uicontrol('style','toggle','string','stop','position',[115,20,40,20],..... 'background','white'); % Text boxes tb1 = uicontrol('style','text','position',[190 20 100 20],'background','w') ; info@assignmentpedia.com
  • 2. tb2 = uicontrol('style','text','position',[320 20 150 20],'background','w') ; drawnow ; % cnt = 1; % Count for Total Random Numbers ccnt = 1 ; % Count for Random Numbers which lie inside circle tic while ~get(stop,'value') % Generate Random Numbers between R and -R x = 2*R*rand(2,1)-R ; set(h,'XData',x(1),'YData',x(2),'Color','b') ; drawnow cnt = cnt + 1; N = sprintf('N = %8.0f',cnt) ; % Update the total number of Random Numbers set(tb1,'String',N) RR = (x(1)^2+x(2)^2) ; if RR<R^2 % If point lies inside the Circle set(h,'XData',x(1),'YData',x(2),'Color','r') ; drawnow ; kssv = 4*ccnt/cnt ; Pi = sprintf('pi(approx)=%6.8f',kssv) ; % Values of pi approximately set(tb2,'String',Pi) ; ccnt = ccnt+1 ; end end toc % Close the figure window set(stop,'style','pushbutton','string','close','callback','close(gcf)') visit us at www.assignmentpedia.com or email us at info@assignmentpedia.com or call us at +1 520 8371215

×