Saving a file with name of reference of other file name ?

2 ビュー (過去 30 日間)
yogesh jain
yogesh jain 2016 年 3 月 30 日
コメント済み: yogesh jain 2016 年 4 月 2 日
Hello all; I want to save two types of file(.stl and .mat) in which one file (.stl) will be saved by user with particular name . I need '.mat' type of file to be saved with having reference of title of '.stl' type file so that I can load .mat file automatically . for example - "abc.stl" and "abc_1.mat" ; "head.stl" and "head1.mat" here I am using .stl file for generating volume data (for saving faces and vertices) and .mat file for saving variables . Thankyou

採用された回答

Walter Roberson
Walter Roberson 2016 年 3 月 30 日
When Filename is the user-provided filename (such as by way of uiputfile() ), then
mat_suffix = '_1.mat';
[filedir, basename, ext] = fileparts(Filename);
matFilename = fullfile(filedir, [basename mat_suffix]);
  1 件のコメント
yogesh jain
yogesh jain 2016 年 4 月 2 日
Thanks a lot Mr. Roberson. It helped

サインインしてコメントする。

その他の回答 (1 件)

David Sanchez
David Sanchez 2016 年 3 月 30 日
Hi, it all depends on how the user introduces the *.stl file name, but taking for granted that the name is somehow available to you, this might help you out:
your_file_name = 'xxx.stl';
your_file_no_ext = your_file_name(1:end-4); % this gets rid of *.stl extension
your_mat_file = strcat(your_file_no_ext,'_1');
save(your_mat_file) % this will save your workspace variables in xxx_1.mat
Of course, you can save specific variables instead of the whole lot,
doc save
will give you the options to do so.

カテゴリ

Help Center および File ExchangeSTL (STereoLithography) についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by