Developing GUI in MATLAB is suitable for real time application?

27 views (last 30 days)
Sairah
Sairah on 7 Aug 2017
Edited: Stephen on 9 Aug 2017
I am developing the GUI for real time application, But in some aspects I found MATLAB get slow during execution. I need a sincere suggestion, do I shift to C# for GUI application? I found C# little easier than MATLAB for GUI application. please help
  10 Comments
Sairah
Sairah on 8 Aug 2017
yes @Walter Roberson I just use image file (generated by AutoCAD)this image file is a Map of the building and then I plot the moving objects on that image file.

Sign in to comment.

Answers (3)

Jan
Jan on 7 Aug 2017
Of course Matlab gets slow during the execution if it has a lot do to. This may be the nature of the problem, e.g. if huge data sizes have to be processedm or a problem of the programming, e.g. for iteratively growing arrays, creation of a large number of graphic objects (instead of updateing the XData, YData, ZData of existing objects).
Matlab's graphics output is not fast. If the job requires e.g. the rendering of complex 3D objects, other programming languages migth be faster. Without knowing any details about the actual problem, it is impossible to draw a reliable conclusion.

Sairah
Sairah on 8 Aug 2017
Edited: per isakson on 8 Aug 2017
Here I am sharing one of my code block in which I use two push buttons, 1st push button reads the image file and the 2nd push button is reading a text file which contains x and y positions of the object and plots the x and y positions on an image.
(Before commenting on this let me tell you guys one thing that I have intermediate programming skill and I am new to MATLAB GUI as well.)
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton1 (see GCBO)
A = imread('HCRC MAP.jpg');
B = imrotate (A,90);
imshow(B);
hold on;
% --- Executes on button press in pushbutton2.
function pushbutton2_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton2 (see GCBO)
tag = [];
fid = fopen('D:\work\MATLAB GUI Programs\GUI_Testing_file.txt');
while ~feof(fid)
line = fgetl(fid);
nums = str2num(line);
tag = [(nums(1)*100); (nums(2)*100)];
plot(620+tag(1),2196-tag(2),'b.', 'LineWidth', 0.1);%90 rotate
hold on
pause(0.001)
end
fclose(fid)

Sairah
Sairah on 8 Aug 2017
Edited: Sairah on 8 Aug 2017
And in another part of the code is using push buttons and one check box.
% --- Executes on button press in start_reception.
function start_reception_Callback(hObject, eventdata, handles)
global flag
flag = 0;
fid = fopen( 'D:\work\MATLAB GUI Programs\GUI_Testing_file2.txt');
while ~feof(fid)
line = (fgetl(fid));
data = str2num(line);
Tag1 = [data(2); data(3)];
Tag2 = [data(5); data(6)];
pause(0.01)
if flag == 0
hold off
plot(Tag1(1), Tag1(2),'rd', Tag2(1), Tag2(2),'bd','MarkerSize',8)
elseif flag == 1
hold on
plot(Tag1(1), Tag1(2),'r.',Tag2(1), Tag2(2),'b.','LineWidth',0.2)
hold off;
elseif flag ==2
flag = 0;
elseif flag == 3
break
end
h = rectangle('Position',[0.45,0.45,(3.60-0.45),(4.50-0.45)],'Curvature',[0.45,0.45],'LineWidth',2,'LineStyle','--');%nominal path
hold on;
axis([0 4 0 5])
end
fclose(fid)
% --- Executes on button press in Track_Tag1.
function Track_Tag1_Callback(hObject, eventdata, handles)
% hObject handle to Track_Tag1 (see GCBO)
global flag
if get(handles.Track_Tag1,'Value') == get(hObject,'Max')
flag = 1
else
flag =2
end
% --- Executes on button press in pushbutton2.
function pushbutton2_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton2 (see GCBO)
if get(hObject,'Value') == get(hObject,'Max')
flag = 3
else
flag = 0
end
  3 Comments
Stephen
Stephen on 9 Aug 2017
@Sairah: MATLAB graphics is based on Objects. The MATLAB documentation explains this clearly:
In practice, per isakson's suggestion means, for example, creating a line just once and thereafter simply changing its properties (e.g. the X and Y data). All useful graphics functions return handles to some object, and the documentation clearly states what kind of object and has a link to that object's properties. So the best thing you could do for your self is start reading the MATLAB documentation and trying the examples.
And did I mention: read the documentation! The more you use it, the easier it will be to find the right information in it.

Sign in to comment.

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!