MATLAB with some BUGS)
5 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
I know MATLAB is one of the powerful tool in many field, I write this question because SO MANY BUGS are makes me crazy.
I use MATLAB 2016a for Image processing and calculating energy resolution about Radiation Detection System. I use webcam class to combine flood images to Real images. But everytime i call webcam instructions supported by MATLAB, MATLAB SHUT DOWN BY ITSELF.
Besides, I build some GUI environments for testing easily. And there are some loops for collecting data. But MATLAB just escapes from loop even i don't use BREAK. I used infinite loops to check this problem. Maybe I think there are some conditions i didn't notice. BUT HE ESCAPES FROM INFINITE LOOPS EVEN I DON'T USE BREAK.
That ridiculous 'Paradigm' breaks my concept of programming. Does anyone suffer from these problems?
17 Commenti
Elias Salomão Helou Neto
il 20 Set 2017
Walter, I would love to have concrete examples. I claim that what you say is simply not true, Matlab gives no productivity boost over Python + libraries. I have been there, done that. Much less debugging with Pyhton than with Matlab, is what I have experienced. I too always want to solve problems. That's what we all want to do. No need to use bold letters, to shout or to be passionate.
Adam, Matlab's documentation is indeed reasonably good, but I happen to find very good documentation for Python libraries too. Even though one needs to go online to get it. The fact that the Python community is larger helps a lot too. Every question is already answered somewhere, although I have yet to find unanswered Matlab questions too.
I agree that the problem with the OP is not Matlab specific. Also, Open Source may not be necessary for everything, but it is alwasya good to have freedom, and it is essential in science, for reproducibility purposes. Admitedly, this is a rather utopic matter, as most hardware is proprietary anyway. However, not having to spend thousands of dollars in software is a plus. You know, you can get very good hardware for this money and it can be a major productivity boost.
For the sum of the reasons I have exposed, I believe that it is a good thing for beginners not to start with Matlab, unless they must. If not, Python is a better tool. It is free, it is more advanced as a programming language, it has a huge library of helpers functions, it is less bug prone, it has a larger programming community, it requires less hardware resourcers, it can be run anywhere (even Android and iOS) and so on.
Walter Roberson
il 20 Set 2017
Elias, you can click on my username and look through my over 10000 contributions here to see evidence that I do indeed answer a lot of questions here about a wide variety of topics in mathematics, engineering, physics, image processing, and other computing.
Risposte (4)
Jan
il 11 Lug 2017
Modificato: Jan
il 12 Lug 2017
I'm absolutely convinced that Matlab does not break out of loops without beeing instructed to do so, never, and under no circumstances. There will be a deterministic reason for exiting the loop. If you post the code, which reproduces the problem, the readers of the forum can help to identify the reason of the behavior, which differs from your expectations.
In opposite to this, the crashes you observe while using the webcam class, sounds like bugs. Can you upgrade to 2017a? Did you send a bug report to MathWorks already? What did they answer? Did you find the problem in the list of reported bugs and do you find a workaround there? Do you get any details about where the code crashs, e.g. in the log files, error messages or from using the debugger?
I do not know any software, which does not contain bugs. The support of MathWorks is much better than the service of the most other software companies. This forum is a marvelous addition. I'm not hapy with the policy to fix bugs by upgrades, because each upgrade contains new features and looses old deprecated ones, and in consequence new bugs are included. In consequence you can write reliable Matlab code by deciding for one release and include many work arounds to cope with the existing bugs. Then upgrading to a newer version becomes more and more horrible. (I'm still running a Matlab 6.5 machine, because I must be able to reproduce the data of publications for 10 years.)
You are right: Matlab contains many bugs. And I love it, because I do not know any other programming language, which has fewer bugs, a greater backward compatibility and a better documentation and support.
PS. I'm not payed by The MathWorks.
[EDITED] A small example for an infinite loop, which is left without a break:
k = 0;
while true
k = k + 1
if k == 10
true = 0;
end
end
You can hide the redefinition of true in an eval or in a subfunction and assignin('Caller') also. There are many other ways to create an unexpetced behavior, but in all cases it is not a problem of the code, but of the expectations.
3 Commenti
Jan
il 11 Lug 2017
Modificato: Jan
il 11 Lug 2017
@Guillaume: I was not precise enough. While C and C++ are perfect, the compilers are not. E.g. the LCC shipped with older Matlab versions failed for accessing int64_T arrays and many header files missed important symbols. After a high optimization, the numerical results can differ, but it is debatable, if this is a bug or a feature. In consequence it is not enough to publish a C source code, but to be sure that others can reproduce the results exactly, the compiler and the used settings are required.
Another point of view is that a program written in C is much more prone for bugs than a Matlab code. It is trivial to srach the machine in C, but really hard to do this in Matlab. There are many workarounds e.g. safer versions of the string libraries, but it is not trivial to use them, see e.g. https://www.sudo.ws/todd/papers/strlcpy.html. Many implementations work with specific compilers only. I'm faced with functions like strncmpi, _strnicmp, strcmpni depending on the used headers and libraries. A lot of preprocessor directives must consider the versions of compilers, libraries and operating systems. The C++ and C99 comment style let the ANSI C compiler stop with an error, except if you allow these comments by using an input flag during the compilation. Brrrrr. Nevertheless, Matlab changed the output of strncmp(a,b,0) without a note in the documentation also some years ago.
When I try to run some Matlab and C code written in 1999, I expect Matlab to need less adjustments to produce the same results.
There have been a bunch of bugs concerning the end command for indexing in Matlab in the last 20 years. In C there is no such command and you can access x(end+1) freely. So my claim that "Matlab has less bugs" might be a question of taste. A new proposal:
Matlab code is more stable in general compared to other
programming languages.
But the comparison is weak: I can share Matlab code using imresize() easily, while expecting that another user can run some C code I use to resize an image is a completely different story.
John D'Errico
il 11 Lug 2017
Yes, but the bugs in question are in a webcam interface. Fortran may have a webcam interface written by some other party, but it will be just as at risk of problems.
John D'Errico
il 11 Lug 2017
Modificato: John D'Errico
il 11 Lug 2017
This is a silly question. Not a question at all, just a rant. Sorry, but that is all. By setting the title as pure flame bait, you are not looking for a constructive answer anyway.
No, I'm not at all surprised. ANY language that tries to deal with hardware interfaces will see lots of bugs. Why? Because hardware changes, CONSTANTLY! And if the hardware stayed fixed, then your OS changes frequently enough that the writers of the package have a hard time keeping up with all changes. Hardware interfaces are a moving target, made more difficult because the platform you are standing on is moving too. Did you change a firewall recently? Install a virus protection tool? For example, I surprised myself when one tool stopped working. No reason at all until I realized I had just made a minor firewall change in something that I thought innocuous, all done because we had replaced our router.
So in all seriousness, yes, I'm sorry, but you can't really be surprised at problems. Use the most recent version, as it may have fixes in it. MATLAB itself is pretty stable. I've not seen a crash in many months, something that is more than I can say for most of the software I use.
0 Commenti
Steven Lord
il 11 Lug 2017
YeeHang, addressing the two main issues you described separately:
But everytime i call webcam instructions supported by MATLAB, MATLAB SHUT DOWN BY ITSELF.
That sounds like there may be a bug in MATLAB, the webcam driver you're using, both. Or there may be a problem with the OS, a physical problem with the hardware, etc. Doing a search of the Bug Reports for "webcam" in release R2016a I only found two hits, and I'm not sure either is related to the problem you described unless you're using a Microsoft Surface Pro 4 built-in camera.
If you're not using a Microsoft Surface Pro 4 I don't know if it would be possible to debug that crash in this forum, so I recommend contacting Technical Support directly using the Contact Us link in the upper-right corner of this page and work with them to determine the cause of the crash and how to correct it.
But MATLAB just escapes from loop even i don't use BREAK. I used infinite loops to check this problem.
Well ... infinite loops may not be infinite depending on how you wrote them.
while true
% do something
end
That's not going to break unless you call break in the "do something" part of the while loop or press Ctrl-C. [Or kill MATLAB using Task Manager (Windows), KILL (Linux, Mac) or similar tools.]
I just launched 32-bit version of an older release of MATLAB (release R2015a) using the -win32 flag and ran this code. That's a pretty fast-running infinite loop, I think.
>> tic
for k = 1:Inf
end
toc
Warning: FOR loop index is too large. Truncating to 2147483647.
Elapsed time is 3.920841 seconds.
You could try to do the same on a 64-bit version of MATLAB, but it would take substantially longer since the loop index would truncate at intmax('int64') rather than intmax('int32').
Anyway, we can't really diagnose what's going on without seeing a small sample of your code. If you don't want to or can't post it here, I recommend sending it to Technical Support when you contact them about the camera-related crash and ask them for help determining why it terminates earlier than you expected.
0 Commenti
Walter Roberson
il 12 Lug 2017
I gather that the loop being exited is a data collection loop. Data collection relies upon the remote end supplying correct data in the correct timing. Timeouts are common, as is the remote end sending something unexpected that your code reacts badly to. It is therefore not uncommon for data collection loops to be exited because data was not available or because what was provided triggers errors in the processing. It would be common for an error to be signaled in these cases -- an error that could be caught with a try/catch block and handled more gracefully.
0 Commenti
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!