フィルターのクリア

load

8 ビュー (過去 30 日間)
Tor Fredrik Hove
Tor Fredrik Hove 2012 年 4 月 26 日
in matlab I can save and load for example like this
>> mymat=rand(2,3)
mymat =
0.2785 0.9575 0.1576
0.5469 0.9649 0.9706
>> save testfile.vg mymat -ascii >> save testfile.vg mymat -ascii >> clear >> load testfile.vg
but in this assignment I was asked to download a file from the internet that was a vector
the assignment said I should load it with this command
TRD = load('TRONDHEIM_MT_Daily.txt');
i saved is as
trondheim_MT_Daily.txt
and it worked to load it
with the way they noted but the filetype is different from other matlab files. I cant find any information about it on internet. Is .txt an own file type and does anyone know where to find information about it if it is?

採用された回答

Titus Edelhofer
Titus Edelhofer 2012 年 4 月 26 日
Hi Tor,
I don't 100% understand the question: .txt is just as .dat or similar an "indicator" that it's a text file (ascii, not yet nothing to do with MATLAB). The load (as you experienced with testfile.vg) is capable of reading "plain" ascii text files. If the text file contains more than just numbers (like header, dates, etc.), then the other functions for reading ascii files come into play (doc iofun gives an overview).
Titus
  1 件のコメント
Tor Fredrik Hove
Tor Fredrik Hove 2012 年 4 月 26 日
I have some problem still thank you for your response.
>> load TRONDHEIM_MT_Daily.txt
works
but if I write
>> clear
>> TRD=load TRONDHEIM_MT_Daily.txt
TRD=load TRONDHEIM_MT_Daily.txt
|
Error: Unexpected MATLAB expression.
Is it not possible to assign load to a variable? And the way they do it above in my question is a way to assign a load directly to a random variable? For example this worked:
>> TRD = load('ed');
>> TRD
TRD =
1 2 3

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

その他の回答 (1 件)

Titus Edelhofer
Titus Edelhofer 2012 年 4 月 26 日
Hi Tor,
if you want to load to a variable you need to use the functional form, i.e.,
TRD = load('Trondheim_MT_Daily.txt');
Note, that the "command" version
load Trondheim_MT_Daily.txt
is equivalent to the "functional" form
load('Trondheim_MT_Daily.txt');
If you need to assign to a variable, you have to use the functional form.
Titus

カテゴリ

Help Center および File ExchangeData Import and Export についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by