Using MATLAB (779505), страница 18

Файл №779505 Using MATLAB (Using MATLAB) 18 страницаUsing MATLAB (779505) страница 182017-12-27СтудИзба
Просмтор этого файла доступен только зарегистрированным пользователям. Но у нас супер быстрая регистрация: достаточно только электронной почты!

Текст из файла (страница 18)

In addition, you might need to restart MATLAB oruse the rehash function before you use the new or updated file. This is becausethe locations of those files are loaded and cached in memory at the beginningof each MATLAB session to improve performance, and changes are not alwaysrecognized automatically.For instructions to view and modify the search path, see “Viewing and Settingthe Search Path” on page 5-15.How the Search Path WorksThe search path is also referred to as the MATLAB path.

Files included areconsidered to be on the path. When you include a directory on the search path,you add it to the path. Subdirectories must be explicitly added to the path; theyare not on the path just because their parent directories are. The search pathis stored in the file pathdef.m.The order of directories on the path is relevant. MATLAB looks for a namedelement, for example, foo, as described here. If you enter foo at the MATLABprompt, MATLAB performs the following actions:1 Looks for foo as a variable.2 Checks for foo as a built-in function.3 Looks in the current directory for a file named foo.m.4 Searches the directories on the MATLAB search path, in order, for foo.m.5-14Search PathAlthough the actual search rules are more complicated because of therestricted scope of private functions, subfunctions, and object-orientedfunctions, this simplified perspective is accurate for the ordinary M-files youusually work with.The order of the directories on the search path is important if there is morethan one function with the same name.

When MATLAB looks for that function,only the first one in the search path order is found; other functions with thesame name are considered to be shadowed and cannot be executed. For moreinformation, see “How MATLAB Determines Which Method to Call”.To see the pathname used, use which for a specified function. For moreinformation, see the reference page for which.Viewing and Setting the Search PathUse the Set Path dialog box to view and modify MATLAB’s search path and seefiles in directories that are on the path.

Equivalent functions are documentedfor each feature of the Set Path dialog box.5-155Workspace, Search Path, and File OperationsSelect Set Path from the File menu, or type pathtool at the CommandWindow prompt. The Set Path dialog box opens.When you click one of these buttons, the change is made to the current searchpath. However, the search path is not automatically saved for future sessions.Directories on the current MATLAB search path.Make changes tothe search path.Save changes foruse in futureMATLAB sessions.Use the Set Path dialog box for the following:• “Viewing the Search Path” on page 5-17• “Adding Directories to the Search Path” on page 5-17• “Moving Directories within the Search Path” on page 5-17• “Removing Directories from the Search Path” on page 5-18• “Restoring the Default Search Path” on page 5-18• “Reverting to the Previous Path” on page 5-18• “Saving Settings to the Path” on page 5-185-16Search PathViewing the Search PathThe MATLAB search path field in the Set Path dialog box lists all of thedirectories on the search path.Function Alternative.

Use the path function to view the search path.Adding Directories to the Search PathTo add directories to the MATLAB search path using the Set Path dialog box:1 Click the Add Folder or the Add with Subfolders button.- If you want to add only the selected directory but do not want to add all ofits subdirectories, click Add Folder.- If you want to add the selected directory and all of its subdirectories, clickAdd with Subfolders.The Browse for Folder dialog box opens.2 In the Browse for Folder dialog box, use the view of your file system toselect the directory to add, and then click OK.The selected directory, and subdirectories if specified, are added to the front(top) of the search path. They remain on the search path until you end thecurrent MATLAB session.

To use the newly modified search path insubsequent sessions, you need to save the path – see “Saving Settings to thePath” on page 5-18.You cannot add method directories (directories that start with @) or privatedirectories directly to the search path. Instead, add their parent directories.Function Equivalent. To add directories to the search path, use addpath. Theaddpath function offers an option to get the path as a string and to concatenatemultiple strings to form a new path.You can include addpath in your startup M-file to automatically modify thepath when MATLAB starts.Moving Directories within the Search PathThe order of files on the search path is relevant – for more information, see“How the Search Path Works” on page 5-14.5-175Workspace, Search Path, and File OperationsTo modify the order of directories within the search path, first select thedirectory you want to move.

Then select one of the Move buttons, such as Moveto Top. The top of the list corresponds to the front of the search path and thebottom of the list corresponds to the end of the search path.The new order of files on the search path remains in effect until you end thecurrent MATLAB session. To use the newly modified search path insubsequent sessions, you need to save the path – see “Saving Settings to thePath” on page 5-18.Removing Directories from the Search PathTo remove directories from the MATLAB search path using the Set Path dialogbox:1 Select the directory to remove.2 Click Remove.The directory is removed from the search path for the remainder of thecurrent MATLAB session. To use the newly modified search path insubsequent sessions, you need to save the path – see “Saving Settings to thePath” on page 5-18.Function Equivalent.

To remove directories from the search path, use rmpath.You can include rmpath functions in your startup M-file to automaticallymodify the path when MATLAB starts.Restoring the Default Search PathTo restore the default search path, click Default in the Set Path dialog box.This changes the search path so that it uses the factory settings.Reverting to the Previous PathTo restore the previous path, click Revert in the Set Path dialog box. Thiscancels any unsaved changes you’ve made in the Set Path dialog box.Saving Settings to the PathWhen you make changes to the search path, they remain in effect during thecurrent MATLAB session.

To keep the changes in effect for subsequent5-18Search Pathsessions, save the changes. To save changes using the Set Path dialog box, clickSave.The search path is stored in the pathdef.m file. By default, pathdef.m is storedin $matlabroot\toolbox\local. On Windows platforms, you can use adifferent pathdef.m if you store it in your startup directory – see “StartupDirectory for MATLAB” on page 1-3.You can directly edit pathdef.m with a text editor to change the path.On UNIX workstations you may not have file system permission to editpathdef.m. In this case, put path and addpath functions in your startup M-fileto change your path defaults.5-195Workspace, Search Path, and File OperationsFile OperationsMATLAB file operations use the current directory as a reference point.

Any fileyou want to run must either be in the current directory or on the search path.Also, when you open a file in MATLAB, the starting point for the file opendialog box is the current directory. The keys tools for performing file operationsare:• Current directory field• Current directory browserCurrent Directory FieldA quick way to view or change the current directory is by using the CurrentDirectory field in the desktop toolbar.To change the current directory from this field, do one of the following:• In the field, type the path for the new current directory.• Click the down arrow to view a list of previous working directories, and selectan item from the list to make that directory become MATLAB’s currentworking directory.

The directories are listed in order, with the most recentlyused at the top of the list. You can clear the list and set the number ofdirectories saved in the list – see “Preferences for the Current DirectoryBrowser” on page 5-30.• Click the browse button (...) to set a new current directory.Current Directory BrowserTo search for, view, open, and make changes to MATLAB related directoriesand files, use the MATLAB Current Directory browser.

Equivalent functionsare documented for each feature of the Current Directory browser.To open the Current Directory browser, select Current Directory from theView menu in the MATLAB desktop, or type filebrowser at the Command5-20File OperationsWindow prompt. You can also open it from the Launch Pad, under MATLAB.The Current Directory browser opens.Use the pathname edit box to viewdirectories and their contents.Click the find button to search for content within M-files.Double-click a fileto open it in anappropriate tool.View the helpportion of theselected M-file.The main file operations you can perform using the Current Directory browserare:• “Viewing and Making Changes to Directories” on page 5-22• “Creating, Renaming, Copying, and Removing Directories and Files” onpage 5-23• “Opening, Running, and Viewing the Content of Files” on page 5-26• “Finding and Replacing Content Within Files” on page 5-28You can also set preferences – see “Preferences for the Current DirectoryBrowser” on page 5-30.5-215Workspace, Search Path, and File OperationsViewing and Making Changes to DirectoriesThe ways to view and make changes to directories are:• “Changing the Current Working Directory and Viewing Its Contents” onpage 5-22• “Adding Directories to the MATLAB Search Path” on page 5-23• “Changing the Display” on page 5-23Changing the Current Working Directory and Viewing Its ContentsTo change the current directory, type the directory name in the pathname editbox in the Current Directory browser, and press the Enter or Return key.

Thatdirectory becomes the current working directory and the files andsubdirectories in it are listed.To view a directory that has recently been displayed, click the down arrow atthe right side of the pathname edit box in the Current Directory browser. Thepreviously displayed directories are listed, sorted by most recent to leastrecent. Select an entry to view the contents of that directory. You can clear thelist and set the number of directories saved in the list – see “Preferences for theCurrent Directory Browser” on page 5-30.To view the contents of a subdirectory within the directory being displayed,double-click the subdirectory in the Current Directory browser, or select thesubdirectory and press the Enter or Return key.

You can also right-click onthat subdirectory and select Open from the context menu.To move up one level in the directory structure, click the up buttonCurrent Directory browser toolbar, or press the Back Space key.in theFunction Alternative. Use dir to view the contents of the current workingdirectory or another specified directory.Use what to see only the MATLAB related files in a directory. With noarguments, what displays the MATLAB related files in the current workingdirectory.

Характеристики

Тип файла
PDF-файл
Размер
6,57 Mb
Материал
Тип материала
Высшее учебное заведение

Список файлов книги

Свежие статьи
Популярно сейчас
Зачем заказывать выполнение своего задания, если оно уже было выполнено много много раз? Его можно просто купить или даже скачать бесплатно на СтудИзбе. Найдите нужный учебный материал у нас!
Ответы на популярные вопросы
Да! Наши авторы собирают и выкладывают те работы, которые сдаются в Вашем учебном заведении ежегодно и уже проверены преподавателями.
Да! У нас любой человек может выложить любую учебную работу и зарабатывать на её продажах! Но каждый учебный материал публикуется только после тщательной проверки администрацией.
Вернём деньги! А если быть более точными, то автору даётся немного времени на исправление, а если не исправит или выйдет время, то вернём деньги в полном объёме!
Да! На равне с готовыми студенческими работами у нас продаются услуги. Цены на услуги видны сразу, то есть Вам нужно только указать параметры и сразу можно оплачивать.
Отзывы студентов
Ставлю 10/10
Все нравится, очень удобный сайт, помогает в учебе. Кроме этого, можно заработать самому, выставляя готовые учебные материалы на продажу здесь. Рейтинги и отзывы на преподавателей очень помогают сориентироваться в начале нового семестра. Спасибо за такую функцию. Ставлю максимальную оценку.
Лучшая платформа для успешной сдачи сессии
Познакомился со СтудИзбой благодаря своему другу, очень нравится интерфейс, количество доступных файлов, цена, в общем, все прекрасно. Даже сам продаю какие-то свои работы.
Студизба ван лав ❤
Очень офигенный сайт для студентов. Много полезных учебных материалов. Пользуюсь студизбой с октября 2021 года. Серьёзных нареканий нет. Хотелось бы, что бы ввели подписочную модель и сделали материалы дешевле 300 рублей в рамках подписки бесплатными.
Отличный сайт
Лично меня всё устраивает - и покупка, и продажа; и цены, и возможность предпросмотра куска файла, и обилие бесплатных файлов (в подборках по авторам, читай, ВУЗам и факультетам). Есть определённые баги, но всё решаемо, да и администраторы реагируют в течение суток.
Маленький отзыв о большом помощнике!
Студизба спасает в те моменты, когда сроки горят, а работ накопилось достаточно. Довольно удобный сайт с простой навигацией и огромным количеством материалов.
Студ. Изба как крупнейший сборник работ для студентов
Тут дофига бывает всего полезного. Печально, что бывают предметы по которым даже одного бесплатного решения нет, но это скорее вопрос к студентам. В остальном всё здорово.
Спасательный островок
Если уже не успеваешь разобраться или застрял на каком-то задание поможет тебе быстро и недорого решить твою проблему.
Всё и так отлично
Всё очень удобно. Особенно круто, что есть система бонусов и можно выводить остатки денег. Очень много качественных бесплатных файлов.
Отзыв о системе "Студизба"
Отличная платформа для распространения работ, востребованных студентами. Хорошо налаженная и качественная работа сайта, огромная база заданий и аудитория.
Отличный помощник
Отличный сайт с кучей полезных файлов, позволяющий найти много методичек / учебников / отзывов о вузах и преподователях.
Отлично помогает студентам в любой момент для решения трудных и незамедлительных задач
Хотелось бы больше конкретной информации о преподавателях. А так в принципе хороший сайт, всегда им пользуюсь и ни разу не было желания прекратить. Хороший сайт для помощи студентам, удобный и приятный интерфейс. Из недостатков можно выделить только отсутствия небольшого количества файлов.
Спасибо за шикарный сайт
Великолепный сайт на котором студент за не большие деньги может найти помощь с дз, проектами курсовыми, лабораторными, а также узнать отзывы на преподавателей и бесплатно скачать пособия.
Популярные преподаватели
Добавляйте материалы
и зарабатывайте!
Продажи идут автоматически
7007
Авторов
на СтудИзбе
261
Средний доход
с одного платного файла
Обучение Подробнее
{user_main_secret_data}