MATLAB How to create a verctor in matlab using data recorded in a text document?

  • Thread starter Thread starter da_coolest
  • Start date Start date
  • Tags Tags
    Data Matlab Text
AI Thread Summary
To create a vector in MATLAB from a text document containing comma-separated values, the user initially attempted to read the file using the fopen and fgetl commands. However, this approach resulted in incorrect indexing, as the command "Y(1)" returned the number 5 instead of the expected value of 58.5698. A recommended solution is to utilize the "importdata" function, which simplifies the process by allowing users to specify delimiters and handle blank lines effectively. This method is more efficient for importing data directly into MATLAB.
da_coolest
Messages
15
Reaction score
0
There is a text document with data separated by the "," sign.

such as 58.5698, 75.2495, 57.1548...

I want to createa vector called Y in MATLAB using these datas. there are 50 values.
i opened the file with the fopen command.
And then tried with the fgetl command. but when I use the "Y(1)" command to get the first value, it produces the number 5 instead of the 58.5698.

Thanks in advance.
 
Physics news on Phys.org

Similar threads

Replies
12
Views
3K
Replies
3
Views
3K
Replies
5
Views
7K
Replies
6
Views
4K
Replies
1
Views
2K
Back
Top