MATLAB Answers

0

How to run NamedPipe stream under parforloop in MatLab Appdesigner

Asked by Ashadullah Shawon on 13 Jul 2019
Latest activity Edited by Ashadullah Shawon on 15 Jul 2019
I am developing a software in matlab that will run two functions simultaneously under parforloop. The first function has a NamedPipe object and the error is: MATLAB cannot determine whether "System" refers to a function or variable. Is the NamedPipe object supported for parforloop? Here is my code
parfor i = 1:2
if i == 1
disp(strcat('Function 1----',datestr(now)));
pause(2);
disp(strcat('Function 1----',datestr(now)));
NET.addAssembly('System.Core');
MypipeServer = System.IO.Pipes.NamedPipeServerStream('my_pipe', ...
System.IO.Pipes.PipeDirection.InOut, ...
System.IO.Pipes.NamedPipeServerStream.MaxAllowedServerInstances,...
System.IO.Pipes.PipeTransmissionMode.Byte,...
System.IO.Pipes.PipeOptions.Asynchronous);
disp("Waiting for client connection...");
MypipeServer.WaitForConnection();
disp("Client Connected");
disp('Reading data from Client');
pause(2);
sr = System.IO.StreamReader(MypipeServer);
%sw = System.IO.StreamWriter('E:/pipeKo.txt')
line = sr.ReadLine();
disp(line);
else
%disp('Function 2');
disp(strcat('Function 2----',datestr(now)));
pause(2);
disp(strcat('Function 2----',datestr(now)));
end
end

  0 Comments

Sign in to comment.

0 Answers