I understand that you want to receive samples from LimeSDR in two different channels simultaneously, and you wish to do so using two separate MATLAB scripts. You also want to stop the scripts on command and store the data in a particular file name format that depends on the starting time and ending time of you receiving samples.
I would encourage you to check out MATLAB’s parallel computing capabilities. Using parallel computing you can run the scripts simultaneously. Refer to this documentation for more context: https://www.mathworks.com/help/parallel-computing/parpool.html
Here is another MATLAB answer that talks about running MATLAB scripts in parallel: https://www.mathworks.com/matlabcentral/answers/318764-how-to-run-two-matlab-scripts-in-parallel
Assuming the two channels work independently of each other, you can base your implementation around this logic:
- Have two separate .m files, one for each channel.
- Create a new script that initiates a parallel pool.
- Create a job for each channel, Job1 and Job2. You can achieve this by creating a job for each script.
- Create another job Job3 that waits for a specified input. When that specified input is received, terminate that script.
- Send a message to Job1 and Job2 that triggers to complete the execution when Job3 is completed. This step is the equivalent of closing your channels.
- When Job1 or Job2 are triggered to terminate by the main script, close the channels and save the results. The main script when triggering could also send the end-time to the Jobs. This step is equivalent to saving the results.
You can get the end time timestamp using the datetime() function. Refer to this documentation to learn more on how to use it: https://www.mathworks.com/help/matlab/matlab_prog/compare-dates-and-time.html
This is only a general idea on how you can implement the solution. Feel free to modify the above steps to your convenience and requirements.