获取文件夹+文件名输出

时间:2018-12-21 19:51:28

标签: matlab

在链接中:[https://www.mathworks.com/help/matlab/creating_guis/interactive-list-box-in-a-guide-gui.html][1]我可以在GUIDE中创建交互式列表框应用

我尝试将{ "name": "obs-web", "version": "0.0.0", "scripts": { "ng": "ng", "start": "ng serve", "build": "ng build", "build-webapp": "ng build --prod", "test": "ng test", "lint": "ng lint", "e2e": "ng e2e", "postinstall": "node build/patch/patch-electron-fs.js" }, "private": true, "dependencies": { "@angular/animations": "^7.1.4", "@angular/cdk": "^6.4.7", "@angular/common": "^7.1.4", "@angular/compiler": "^7.1.4", "@angular/core": "^7.1.4", "@angular/forms": "^7.1.4", "@angular/http": "^7.1.4", "@angular/material": "^6.4.7", "@angular/platform-browser": "^7.1.4", "@angular/platform-browser-dynamic": "^7.1.4", "@angular/router": "^7.1.4", "chacha": "^2.1.0", "core-js": "^2.5.4", "crypto-pouch": "^3.1.3", "hammerjs": "^2.0.8", "moment": "^2.22.2", "node-gyp": "^3.8.0", "npm": "^6.4.1", "pouchdb": "^7.0.0", "pouchdb-find": "^7.0.0", "primeicons": "^1.0.0", "primeng": "^6.1.6", "rxjs": "^6.3.3", "stream": "0.0.2", "tslib": "^1.9.0", "zone.js": "~0.8.26" }, "devDependencies": { "@angular-devkit/build-angular": "~0.11.0", "@angular/cli": "~7.1.4", "@angular/compiler-cli": "^7.1.4", "@angular/language-service": "^7.1.4", "@types/jasmine": "^2.8.11", "@types/jasminewd2": "^2.0.6", "@types/node": "^8.10.38", "codelyzer": "~4.2.1", "jasmine-core": "~2.99.1", "jasmine-spec-reporter": "~4.2.1", "karma": "^3.1.1", "karma-chrome-launcher": "~2.2.0", "karma-coverage-istanbul-reporter": "^2.0.4", "karma-jasmine": "~1.1.1", "karma-jasmine-html-reporter": "^0.2.2", "protractor": "^5.4.1", "ts-node": "~5.0.1", "tslint": "~5.9.1", "typescript": "~3.1.6" } } 行添加到function listbox1_Callback(hObject, eventdata, handles)的末尾,因此我可以得到路径,名称和扩展名的输出(例如F:/user/mySoft.m),但是这是行不通的。我该怎么办?

fullFileName = [path,name,ext]

1 个答案:

答案 0 :(得分:1)

要构建完整文件地址,可以使用fullfile函数。

fullfile(path1,path2,...,filename)

但我认为您想这样做

which(filename)

当您使用变量 filename 调用文件时, which 命令将为您提供文件的完整地址。

示例代码:

filename="mySoft.m"; %this file does not exist in my computer
address=which(filename);
filename="dosyaBul.m"; %this does exist
address=which(filename)

输出:

address =

  0×0 empty char array


address =

    'C:\Users\volk\Dropbox\folder\Matlab\dosyaBul.m'

请注意,您还可以使用pwd在Matlab上获取活动文件夹。就我而言:

>>pwd

ans =

'C:\Users\volk\Dropbox\folder\Matlab'