MATLAB Projects

I've created MATLAB code here that produces a graph and depending on parameters (some random) converges to a different a

I want to be able to run this 100 times for a certain set of parameter values and take an average of the amount of groups that it produces.

Here is the code I have at the minute. Do I need to create another m file for this or can i do it within the function I've already created? [code]function [t seqBeliefs] = extendedHK(n, tol, adj) %extendedHK Summary of function goes here %Detailed explanation goes here beliefs = rand(n,1); seqBeliefs = beliefs; %NxT matrix converge = 0; step = 0 t = step while converge ~= 1 step = step+1; t = [t step]; A = zeros (n,n); for i=1:1:n for j=i:1:n if abs(beliefs(i) - beliefs(j)) < tol && adj(i,j)==1 A(j,i)=1; A(i,j)=1; end end end beliefs = A*beliefs./ sum(A,2); seqBeliefs = [seqBeliefs beliefs]; if sum(abs(beliefs - seqBeliefs(:,step)))<1e-12 converge = 1; end end plot(t,seqBeliefs) end %%in command window type adj=random_graph(n) then call extendedHK function %%with same n then tol value and 'adj'[/code]


JLCPCB – Prototype 10 PCBs for $2 (For Any Color)

China’s Largest PCB Prototype Enterprise, 600,000+ Customers & 10,000+ Online Orders Daily
How to Get PCB Cash Coupon from JLCPCB: https://bit.ly/2GMCH9w

Syed Zain Nasir

I am Syed Zain Nasir, the founder of <a href=https://www.TheEngineeringProjects.com/>The Engineering Projects</a> (TEP). I am a programmer since 2009 before that I just search things, make small projects and now I am sharing my knowledge through this platform.I also work as a freelancer and did many projects related to programming and electrical circuitry. <a href=https://plus.google.com/+SyedZainNasir/>My Google Profile+</a>

Share
Published by
Syed Zain Nasir