0

GUI を作成し、uiimport を使用してデータセットを matlab ワークスペースにインポートしました。このインポートされたデータを matlab の別の関数に渡したいです...このインポートされたデータセットを別の関数に渡すにはどうすればよいですか....diz を試してみました。 ..しかし、それはdizを選ぶことができませんでした....matlabワークスペース上のデータを選びません....何かアイデアはありますか??

[file_input, pathname] = uigetfile( ...
{'*.txt', 'Text (*.txt)'; ...
'*.xls', 'Excel (*.xls)'; ...
'*.*', 'All Files (*.*)'}, ...
'Select files');

uiimport(file_input);
M = dlmread(file_input);
X = freed(M);
4

2 に答える 2

1

このステートメントの結果を割り当てる必要があると思います:

uiimport(file_input);

このように変数に

dataset = uiimport(file_input);

それを次の関数に渡します。

M = dlmread(dataset);

これは、Matlab の非常に基本的な機能であり、Matlab のオンライン ヘルプとドキュメントの一部を読む価値があることを示唆しています。これを行うと、おそらくこれを行うためのより適切で迅速な方法が見つかるでしょう。

編集:まあ、@ティム、他のすべてがRTFMに失敗した場合。だから私はそうしました、そして私の前の答えは間違っています。渡す必要がdlmreadあるのは、読み取るファイルの名前です。したがって、ファイルの読み取りにはuiimportまたはのいずれかを使用しますが、両方を使用することはできません。dlmreadどちらを使用するかは、何をしようとしているのか、および入力ファイルの形式によって異なります。だから、RTFMに行って、私も同じことをします。それでも問題が解決しない場合は、質問を更新し、ファイルの内容の詳細を提供してください。

于 2010-04-25T10:25:07.560 に答える
0

In your script you have three ways to read the file. Choose one on them depending on your file format. But first I would combine file name with the path:

file_input = fullfile(pathname,file_input);

I wouldn't use UIIMPORT in a script, since user can change way to read the data, and variable name depends on file name and user.

With DLMREAD you can only read numerical data from the file. You can also skip some number of rows or columns with

M = dlmread(file_input,'\t',1,1);

skipping the first row and one column on the left. Or you can define a range in kind of Excel style. See the DLMREAD documentation for more details.

The filename you pass to DLMREAD must be a string. Don't pass a file handle or any data. You will get "Filename must be a string", if it's not a string. Easy.

FREAD reads data from a binary file. See the documentation if you really have to do it.

There are many other functions to read the data from file. If you still have problems, show us an example of your file format, so we can suggest the best way to read it.

于 2010-04-26T16:37:44.847 に答える