Is it possible to create a shortcut for a function?
6 ビュー (過去 30 日間)
古いコメントを表示
I use Yalmip to achieve optimization. And when debugging, I use value() function a lot to see the value of the variables. But it is tedious and unefficent. I have to input in the command window value() and then copy the variable in the code, and then paste it. So I wanna if there is a way that I can create a shortcut for the function value(), so that everytime I want to see the value I just select the content that I need and click the shortcut and then things appear in the command window.
0 件のコメント
回答 (1 件)
Keshav
2023 年 7 月 31 日
In MATLAB, it is not possible to create a custom shortcut for your task directly. However, you can write your own script to simplify the task. By creating a script, you can automate the process of applying the 'value' function to the selected item and printing the result. Once you have the script, you can easily see the value by selecting the content and running the script.
You can refer to the following script, which applies the 'value' function to the copied text and displays the output:
% Get the selected content
selectedContent = clipboard('paste');
% Evaluate the selected content using the value() function
result = evalin('base', ['values(', selectedContent, ')'])
By using this script, you can simply copy the desired content and run the script (by entering script file name in the command window) to see the corresponding value.
You can read more about ‘evalin’ function in the below MathWorks documentation.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Get Started with MATLAB についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!