필터 지우기
필터 지우기

I Want Users Browse The File, But It Affects to My Script

조회 수: 1 (최근 30일)
Alvi Syahrin
Alvi Syahrin 2013년 5월 11일
I have a file named 'cobat'. Cobat is a *txt file, tab delimited, consisted of 3 coloumns, so it's a table. I load it manually into this script:
I want users browse their own file. How can I do it? Is this code correct:
[filename pathname] = uigetfile(('.txt'), 'Browse Your File')
Here are my problems:
1. I think it is only for text file, not tab delimited (table). I think I have to use uitable, but I don't understand how to implement it, because the file (cobat) should be loaded.
2. And, if it has been implemented, I can't write 'cobat' in my script, like this:
[g c] = kmeans(cobat,k,'dist','SqEuclidean');
y = [cobat g]
Then I have to change 'cobat' to what name?
Thank you.

채택된 답변

Image Analyst
Image Analyst 2013년 5월 11일
Maybe something like this:
[baseFileName folder] = uigetfile(('.txt'), 'Browse Your File');
fullFileName = fullfile(folder, baseFileName);
myData = csvread(fullFileName);
[g c] = kmeans(myData ,k,'dist','SqEuclidean');
  댓글 수: 2
Alvi Syahrin
Alvi Syahrin 2013년 5월 11일
편집: Alvi Syahrin 2013년 5월 11일
Thank you. Well, this is working, but it only takes the first coloumn of my file. I need the first, second, third coloumns are loaded too. Do you have any idea?
Image Analyst
Image Analyst 2013년 5월 11일
Try dlmread if your delimeter is a tab, not a comma. Otherwise try textscan().

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Get Started with MATLAB에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by