A general view of your import options from text files to matlab is found here http://se.mathworks.com/help/matlab/import_export/supported-file-formats.html
One of the simplest import types for numbers is to use the command
load file.txt -ascii
This produces a matrix variable calles file
Here is a small example borrowed from mathworks
a = magic(4);
b = ones(2, 4) * -5.7;
c = [8 6 4 2];
save -ascii mydata.dat a b c
clear a b c
load mydata.dat -ascii
Note that the above works only for import of numbers.
If you use instead xlsread to read Exceldata. Again a small example borrowed from mathworks
Create an Excel file named myExample.xlsx.
values = {1, 2, 3 ; 4, 5, 'x' ; 7, 8, 9};
headers = {'First','Second','Third'};
xlswrite('myExample.xlsx', [headers; values]);
Sheet1 of myExample.xlsx contains (layout below is lost):
First Second Third
1 2 3
4 5 x
7 8 9
Read data from the first worksheet.
filename = 'myExample.xlsx';
A = xlsread(filename)
A =
1 2 3
4 5 NaN
7 8 9
xlsread returns the numeric data in array A.
To put the above into a structure, e.g. called MyExample, I believe (I have not tested it) you can write
Generally, variables present in a 'structure' may be in character form. Extract it and convert in float etc, as per your need. Similarly, if you want to append in a structures then first convert into character form
If it is written in a text file then read variables with position in line. Convert character form of data into float, integer etc.
i construct big program for multibody analysis for some part .my problem come due to insert variables (only numbers)to program ,i define it individually in m file and this become source of error at output curves so i need to make structure to these variables and load them from text files hoping solve my problem .
if any one have example to case smellier to me ,i will be glade to him .