필터 지우기
필터 지우기

load specific file - make name

조회 수: 2 (최근 30일)
N
N 2014년 6월 14일
답변: Image Analyst 2014년 6월 14일
I would like to choose specific files to open, without having to type the filename or select it. Specifically I have files with number 1 through 10. I would like to first use input to let me choose a number. And then I would like to load that specific file. However that doesn't work for me. Can anybody help? The filesnames are for example: 'filtered_emg_1.mat'
k = input('Please give number filtered emg file : ');
emgdata = load('filtered_emg_' k '.mat');

채택된 답변

Azzi Abdelmalek
Azzi Abdelmalek 2014년 6월 14일
편집: Azzi Abdelmalek 2014년 6월 14일
k = input('Please give number filtered emg file : ');
emgdata = load(['filtered_emg_' num2str(k) '.mat']);
%or
emgdata = load(sprintf('filtered_emg_%d.mat',k))
  댓글 수: 1
N
N 2014년 6월 14일
Thank you ! This was exactly what I needed !

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

추가 답변 (1개)

Image Analyst
Image Analyst 2014년 6월 14일
Seems not very user friendly to me. Why use such a primitive method? At the very least, use inputdlg() instead of input(). But better, why don't you have a listbox with all the files listed where the user can simply click on the filename? That would be so much nicer for your user and you can make sure that only files exiting are listed - the user won't have to worry about typing in a "missing" number. See MAGIC_GUI or Tutorial for GUIDE

카테고리

Help CenterFile Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by