Quantcast
Channel: Recent Questions - Stack Overflow
Viewing all articles
Browse latest Browse all 12111

How to fix "Dot indexing is not supported for variables of this type" on importdata()'s results

$
0
0

I'm trying to import the data from a csv file. When the data is imported, a structure is created with two fields, but neither are accessible, as a dot indexing error is thrown.

These are the first few lines of one of the files

"U0[m/s] U0_Sd U[m/s ]  U_Sd L[N ]  D[N] Horiz. Verti. 4/3/2019 3:21 PM""12.933 0.056   13.919  0.914 -177.404  -262.059    0.000   0.000""12.977 0.050   14.038  0.972   -177.387    -262.139    0.100   0.000""12.947 0.053 14.073    1.040   -177.299    -262.086    0.200   0.000""12.965 0.051   14.007  1.037   -177.271    -262.140    0.300   0.000"

The code is as follows:

path='directory_path';files=dir(strcat(path,'*.csv'));for file=files'    cur_file=(strcat(path,file.name));    file_struct=importdata(cur_file);    file_data=file_struct.data;end

The error I get is "Dot indexing is not supported for variables of this type", but structures should be able to dot index. Additionally, when I go to the workspace, the variable file_struct shows up as a cell rather than a structure, but only does so when I include the line of code initializing file_data. Why is it converting the struct to a cell and how can I access my data? Thanks in advance.


Viewing all articles
Browse latest Browse all 12111

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>