Help me to access folder in the parent directory. suppose I have 2 folders
E:\Bless\Project\LEARNING\myFolder\var.mat
E:\Bless\Project\TESTING\myPgm.m
I have to load a variable from the folder "myFolder" througn the myPgm.m program. Now I specify the entire path in
load "E:\Bless\Project\LEARNING\myFolder\var"
Is there any simple way to specify the path of var.mat?

 채택된 답변

Shashank Prasanna
Shashank Prasanna 2013년 2월 23일

2 개 추천

If you are in: E:\Bless\Project\TESTING\
You can try the following without using the absolute path:
load('..\LEARNING\myFolder\var.mat')
If the folders are in the path then you can do the following:
>> load(which('var.mat'))

댓글 수: 1

Rather, use
load('.\LEARNING\myfolder\var.mat')
This allowed me to skip to my current directory. The ../ did not work. Do not use the which() function unless all your files have unique names!

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

추가 답변 (0개)

카테고리

도움말 센터 및 File Exchange에서 Search Path에 대해 자세히 알아보기

태그

질문:

2013년 2월 23일

댓글:

2021년 5월 10일

Community Treasure Hunt

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

Start Hunting!

Translated by