Developing GUI in MATLAB is suitable for real time application?
古いコメントを表示
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 件のコメント
Adam
2017 年 8 月 7 日
Speed is not generally much of an issue in the GUI aspect of an application, more what you actually do 'under the hood'. Which aspect of the GUI are you concerned about being slow? Usually user-response time is not so fast as to make GUI-specific commands very time-sensitive, but it depends what you are looking to do.
" I need a sincere suggestion, do I shift to C# for GUI application? "
How are we supposed to know? You explained nothing about what your code does, what bottlenecks it has, or how you tested it.
Do you have experience writing efficient MATLAB code? If you show us the code or give a much more detailed explanation then we might be able to help you.
Sairah
2017 年 8 月 7 日
Adam
2017 年 8 月 7 日
How are you plotting the data? Repeated calls to plot will be slow. If you are updating the same plot with new real time data then you should always keep a handle to the original plotted line and update its XData and YData properties (and any others that may need changing) so that you only have one call to the plot function.
There are a lot of code optimisations possible in any language, but it depends entirely on your code and what the profiler says is the bottleneck.
If the bottleneck literally Matlab plotting instructions that are already optimally handled with as few calls to the expensive functions as possible then you may be at the limit of speed, but otherwise there could be huge improvements.
e.g. someone posted code recently that was slow because it was running a loop a few million times. Within the loop they were accessing an edit box and calling str2double on its contents. This resulted in 14 million calls to this function when it could just be taken out of the loop and called once. This speeded up the result a lot.
doc profile
will help you work out where your bottlenecks are, but be careful how you use it and interpret it for a GUI - make sure that you aren't looking at idle time counted in certain functions while it is actually waiting for user input.
Jan
2017 年 8 月 7 日
@Sairah: "called the image CAD file" might be a problem, but it is not clear, what this means exactly. Real-time processing and the slow hard disk access are not matching well together.
Sairah
2017 年 8 月 8 日
Walter Roberson
2017 年 8 月 8 日
Is the CAD file being generated over and over again by an external program? Are you making calls to an external program asking it to generate a new version of the CAD file?
Is there a reason you are not using a constant CAD image (with no people on it) and then drawing the people on top of that in MATLAB ?
回答 (3 件)
Jan
2017 年 8 月 7 日
1 投票
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
2017 年 8 月 8 日
編集済み: per isakson
2017 年 8 月 8 日
3 件のコメント
per isakson
2017 年 8 月 8 日
編集済み: per isakson
2017 年 8 月 8 日
Creating graphic objects is expensive. Thus, plot(...) inside a loop is slow. It's faster to keep the objects and change their property values.
Sairah
2017 年 8 月 8 日
@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.
カテゴリ
ヘルプ センター および File Exchange で 그래픽스 객체 식별 についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!