Dot indexing is not supported for variables of this type.

1 回表示 (過去 30 日間)
Özgür Alaydin
Özgür Alaydin 2020 年 10 月 2 日
コメント済み: Özgür Alaydin 2020 年 10 月 5 日
I have a csv file. in the function, this file should be read and then processed.
But i get error 'Dot indexing is not supported for variables of this type.'
How can i solve this? I attached my csv file.
Thnaks
  3 件のコメント
Utkarsh Belwal
Utkarsh Belwal 2020 年 10 月 5 日
I think that you are using the dot(.) operator instead of a multiplication operator(*). Please share your code if this doesn't resolve the error.
Walter Roberson
Walter Roberson 2020 年 10 月 5 日
There is text part way through the file. If you were not sufficiently careful in reading it you might have ended up with an empty variable where you expect a struct.

サインインしてコメントする。

採用された回答

Luciano Garim
Luciano Garim 2020 年 10 月 5 日
Hi, Özgür Alaydin.
To fix your problem you may transform your csv data in matrix. This way, you can make any mathematical operation.
a = fopen('filename.csv');
b = textscan(a, '%s %s %s %s', 'delimiter', ',', 'CollectOutput',true);
I hope I helped you!
  2 件のコメント
Walter Roberson
Walter Roberson 2020 年 10 月 5 日
That would be a bit strange.
Lines 1 and 503 of the input file contain text. Lines 2 to 501 and 504 to 1003 contain two numeric values per line.
When you use the above code to read the file, you will get results like
{'wl' } {'n' } {0×0 char} {0×0 char}
{'2.0664e-01'} {'1.0648e+00'} {0×0 char} {0×0 char}
{'2.0705e-01'} {'1.0667e+00'} {0×0 char} {0×0 char}
{'2.0746e-01'} {'1.0686e+00'} {0×0 char} {0×0 char}
and eventually
{'1.2398e+01'} {'3.1390e+00'} {0×0 char} {0×0 char}
{'wl' } {'k' } {0×0 char} {0×0 char}
{'2.0664e-01'} {'2.2263e+00'} {0×0 char} {0×0 char}
{'2.0705e-01'} {'2.2310e+00'} {0×0 char} {0×0 char}
This would not be well suited for numeric processing.
If you are going to read the data as text you might as well use fileread() and techniques such as regexp() to parse the text.
Özgür Alaydin
Özgür Alaydin 2020 年 10 月 5 日
Thanks for answer, i solved problem.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCell Arrays についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by