Open MATLAB path document in linux terminal

Basically I want something similar to matlab's `open some_script.m` command but in a terminal without launching matlab (not even matlab -nonsplash because it still takes time)
Why I want to do this? I use vscode to type my scripts, and sometimes I need to check the content of some functions in my matlab path. I am curious if there is some quick way to do this.
Please let me know if you need more clarification. Thanks!

댓글 수: 1

Answering my own question after a few years.
I do like to work in VSCode on editing matlab scripts, but it is probably easier to run and debug the code in the real MATLAB IDE. I will open both at the same time, and I would find the path to the matlab function I am interested in with in the MATLAB terminal (or in terminal matlab -nonsplash)
which interested_function.m
This will print out the path to the function I want to look at.
Then, in terminal or VSCode terminal, type
code the/path/of/the/interested_function.m
This will open up this function in VSCode to view and edit.

댓글을 달려면 로그인하십시오.

답변 (1개)

Yash
Yash 2023년 9월 1일

0 개 추천

If you want to quickly view the content of MATLAB script files (.m) in your terminal without launching MATLAB, you can navigate to your MATLAB path by using the cd command and to view the scripts you can use various command-line text editors or viewers in linux. Here are a few options:
  1. cat Command: You can use the cat command to display the content of MATLAB script files in your terminal.
cat some_script.m
This will display the content of some_script.m directly in the terminal.
  • less Command: The less command allows you to view the content of a file one screen at a time. To view a MATLAB script
less some_script.m
You can scroll through the file using the arrow keys and exit by pressing q.
  • more Command: Similar to less, the more command lets you view files page by page
more some_script.m
This will display the content of some_script.m in the terminal.
  • vim Command: The most basic text editor available on linux platform.
vim some_script.m
Using these commands, you can quickly check the content of MATLAB script files without launching MATLAB or using any GUI-based editors. This should work well with VS Code, as you can open your terminal directly within VS Code and use these commands there.
I hope this helps.

카테고리

도움말 센터File Exchange에서 Environment and Settings에 대해 자세히 알아보기

제품

릴리스

R2023a

질문:

2023년 8월 31일

댓글:

2026년 4월 20일 17:04

Community Treasure Hunt

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

Start Hunting!

Translated by