Trying my script in another MATLAB release
3 ビュー (過去 30 日間)
古いコメントを表示
Hi, I have MATLAB R2015b, and I have a script I would like to test in another MATLAB release, to see if it still works. I would like my script to be able to run in any release, or at least in as many releases as possible.
If you run it, can you tell me the error message that appears and how I can solve it?
5 件のコメント
Image Analyst
2017 年 1 月 13 日
Well I thought that too. It's a little unclear though if "the error message" also appears in his R2015a version or not. If there's no error message the only reason I think it wouldn't run in a later version is if he used a deprecated function that has since been removed. And it wouldn't run in an older version if he used a new function that didn't exist in the old version. The help documentation tells whether functions are deprecated and when they were first introduced so that may help him determine compatibility.
採用された回答
Jan
2017 年 1 月 12 日
This is a really ugkly start of a function:
clear variables, whitebg('w'), close all; clc, format compact, format long
- clear variables clears all currently existing variables in the current workspace. At the start of a function this is meaningless, so simply omit it.
- Setting the standard behavior with whitbg, and format might interfere with the preferences of other users. Therefore it is unfriendly to modify the default.
- close all closes other dialog windows of Matlab. This impedes working with different programs and other users might hate, if your program deletes their work.
- Clearing the CommandWindow by clc might hide important information like warning or error message. I would avoid it.
The code is monolitic. Splitting it into subfunction and using loops to avoid repeated code blocks would simplify it substantially. Then you can run unit-tests for the subfunctions to check, if they work as expected under different Matlab versions. Currently testing or debugging the code is nearly impossible, because it is one single massive block and contains too few comments to define the purpose of the code lines clearly.
If you have to adjust the code for a specific Matlab versions, many many almost equal editings are required. I'm sure that this cannot be done without typos. Using loops instead and subfunctions would be much simpler and more clear and than editing a single line would be enough.
Avoid gimmicks like pause(eps) . It might look funny, but pause uses a resolution of 0.01 seconds.
Hiding indices in the names of variables like "tx10", "p1" etc. is a bad idea. Using arrays instead will simplify the code.
Writing more than one command per line impedes Matlab's JIT acceleration and the debugging.
This disables a warning, which is thought to point out limitations with running on different Matlab versions:
warning('off','MATLAB:HandleGraphics:ObsoletedProperty:JavaFrame');
If you intention is to run the code with as many releases as possible, better use a method with TRY-CATCH.
1 件のコメント
その他の回答 (2 件)
Image Analyst
2017 年 1 月 11 日
You didn't say what to enter for inputs. I'm running R2016b and I put in 1 for all the inputs and it ran for a while and then crashed with this error message:
To use 'local2globalcoord', the following product must be both licensed and installed:
Phased Array System Toolbox
I don't have that toolbox. I've added it to the Products section above.
3 件のコメント
Walter Roberson
2017 年 1 月 12 日
R2014a:
Error using contour3 (line 65)
Too many input arguments.
Error in x1 (line 185)
contour3(x,y,z,30,'-','linewidth',1), title(string_3,'interpreter','latex','FontSize',13), axis equal, pause(2) % pause(0.1)
3 件のコメント
Walter Roberson
2017 年 1 月 12 日
The work-around is probably
[~, h] = contour3(x,y,z,30,'-');
set(h, 'LineWidth', 1);
This should work for both R2014a and before, and for R2014b and later. In R2014b and later, h would be a contour object, which has a LineWidth property directly. In R2014a and earlier, in the special case that you specified a linespec (which you did) then the h returned would be a vector of line objects, and those have LineWidth properties too.
If you had not specified '-' then in R2014a and earlier then h would be patch objects -- and they happen to have LineWidth properties as well.
参考
カテゴリ
Help Center および File Exchange で Performance and Memory についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!