- I don't think ImportData is an appropriate name. It is too close to importdata.
- The output argument, A, is not assigned a value in the function.
text file columns assistance
8 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
i have a text file with data such as
a1 10
a2 6
etc.
when i use:
function A = ImportData() %ImportData function
FileName = uigetfile('*.txt','Select the MATLAB code file')
assignin('base','A',importdata(FileName))
to import the file, it imports everything under A then if i try to assign a1=A(1,2) it is returning a1 10 instead of just 10. if i use uiimport it wont seperate the columns either. how do i structure the txt file into columns?
0 Kommentare
Antworten (1)
per isakson
am 25 Aug. 2012
Bearbeitet: per isakson
am 25 Aug. 2012
Strange!
I would expect importdata to return a structure in this case.
>> a=importdata('cssm.txt' )
a =
data: [2x1 double]
textdata: {2x1 cell}
rowheaders: {2x1 cell}
>> a.data
ans =
10
6
>> a.textdata
ans =
'a1'
'a2'
>> a.rowheaders
ans =
'a1'
'a2'
where cssm.txt contains
a1 10
a2 6
with space between the columns.
I guess that there is a delimiter between the columns (column separator), which is not recognized by importdata.
See the help:
A = importdata( filename, delimiter )
.
You write "... a1=A(1,2) it is returning a1 10 ...". What does
double( a1 )
return?
0 Kommentare
Siehe auch
Kategorien
Mehr zu Large Files and Big Data finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!