exahange data between matlab script and simulink block diagram
4 views (last 30 days)
I have a simulink file which contains many subsystems, I need to implement the Genetic algorithm to optimize 20 variables in this simulink file, so the first thing I did is generating random binary numbers in the matlab file then convert it to decimal in a certain way as mentioned in the genetic algorithm. My questions are: 1- I want to send these numbers to the simulink block diagram instantly and run the simulink (from matlab)to get the output and feed back this output to the matlab file to do some calculations and repeat the previous steps until the output in the simulink reaches the desired value, how to send those values from matlab file to the simulink file?
2-I read that I can run the simulink in a parallel way, since my code should do the following: a- Generating a number of data sets each data set contains 20 numbers. b- send those data sets in a parallel way to the simulink in order to calculate the output for each data set. c- send the outputs to the matlab file to do some calculations, if the error is still high go to step (a). else stop the program and save the required data. Can any one help me to how to do this communication between matlab file and simulink block diagram? also, the simulink block diagram has many subsystems, connected together, since I read that in order to send something from matlab to simulink I must use set_param function, how to deal with those variables which will be sent from matlab as parameters? Could you please help me, Thank you, Sali