hi,
I have a text file like,
File:
100_at,23,45
120_rt,56,76
125_dr,34,23
109_at,90,98
i want to fill this data into a structure file or in a matrix, so that i can access each data in the file.
please help me to solve this problem.
thanks in advance....
|
|
0
|
|
|
|
Reply
|
keyani
|
1/6/2011 4:36:04 AM |
|
On 05/01/11 10:36 PM, keyani gnanapragasam wrote:
> I have a text file like,
> File:
> 100_at,23,45
> 120_rt,56,76
> 125_dr,34,23
> 109_at,90,98
>
> i want to fill this data into a structure file or in a matrix, so that i
> can access each data in the file. please help me to solve this problem.
fid = fopen('File:', 'rt');
datacell = textscan(fid, '%s%f%f', 'Delimiter', ',');
fclose(fid);
datastruct = struct('Field1', datacell{1}, 'Field2', datacell{2},
'Field3', datacell{3});
The result will be a structure array, one array element per row, with
the field named "Field1" containing the initial string, the field named
"Field2" containing the first number, and the field named "Field3"
containing the second number.
Putting it in to a matrix requires more information from you about the
shape you want the matrix to be, as it would be necessary to use a cell
matrix rather than an ordinary numeric matrix.
|
|
0
|
|
|
|
Reply
|
Walter
|
1/6/2011 7:45:22 AM
|
|
|
1 Replies
265 Views
(page loaded in 0.453 seconds)
Similiar Articles: filling left side of string - comp.lang.awkfilling a structure file - comp.soft-sys.matlab filling left side of string - comp.lang.awk... in comparing function not in printing. So with the set /p I have only ... "Fill" in Matlab ??? - comp.soft-sys.matlabfilling a structure file - comp.soft-sys.matlab hi, I have a text file like, File: 100_at,23,45 120_rt,56,76 125_dr,34,23 109_at,90,98 i want to fill this data into a ... Fill between curves that are functions, not data series - comp ...filling a structure file - comp.soft-sys.matlab Fill between curves that are functions, not data series - comp ... filling a structure file - comp.soft-sys.matlab Fill ... matlab complier, Cannot open include file: 'mclmcrrt.h' - comp ...Fill a matrix without for-loop - comp.soft-sys.matlab matlab complier, Cannot ... filling a structure file - comp.soft-sys.matlab We created the new h file, but we got error ... Acrobat 6 Pro Math.round function - comp.text.pdffilling a structure file - comp.soft-sys.matlab Acrobat 6 Pro Math.round function - comp.text.pdf (1) // fill in average units field this.getField("Average.0 ... Help needed: read 3-dimensional array from a MAT-file in Fortran ...filling a structure file - comp.soft-sys.matlab... comp.soft-sys.matlab Structure array ... read 3-dimensional array from a MAT-file in Fortran 90 MAT file structure Re ... Populate form-fillable pdf from command line - comp.text.pdf ...If I understand right what you want to do, then a FDF file should do it ... Barcode - comp.text.pdf doc.Close() End Function This is ... How to Fill in a PDF Form ... Structure array HELp - comp.soft-sys.matlabfilling a structure file - comp.soft-sys.matlab Structure array HELp - comp.soft-sys.matlab Structure array HELp - comp.soft-sys.matlab Help needed: read 3-dimensional ... Fill Command? - comp.soft-sys.matlab... to shade areas of a spoke wheel pattern according to a function that I choose. I am using the fill ... comp.lang.awk I am accepting a value entered from batch file using ... Could anyone give me the spice-mode.el - comp.emacsFrom the website, I found a package called spice-mode.el. But I could not access to it. Could anyone kindly help me send that file to me? Regards Roger homework - C - Filling a structure from a text file - Stack OverflowMy advice is to refer to your course notes/textbook and start writing code. Honestly you will learn nothing by taking a completed program from the answers here. Using strtok to fill a structure from a text file? - C BoardUsing strtok to fill a structure from a text file? This is a discussion on Using strtok to fill a structure from a text file? within the C Programming forums, part of ... 7/22/2012 2:34:08 PM
|