Reading txt file from VBA for Matlab

2 ビュー (過去 30 日間)
sko
sko 2020 年 12 月 1 日
回答済み: Rishik Ramena 2020 年 12 月 4 日
I am working parallel with Excel and VBA in order to create txt files I wish to use for MATLAB. However, I experience some format issues I can't resolve.
For instance, the following VBA
Open "example.txt" For Output As #1
For i = 1 To 5
Print #1, Sheets("Example").Cells(i + 3, 3)
Next i
Indeed prints numbers (reals) it is supposed to however MATLAB struggles with reading this example .txt file.
There are some characters VBA is printing. I don't know how to delete those within a VBA code or tell somehow Matlab how to read this file
Example.txt opened in matlab. Note the NaN read by MATLAB from a text file:
  2 件のコメント
VBBV
VBBV 2020 年 12 月 1 日
It occurs when the file has special characters or space. Matlab converts them as NaN which means Not a Number if the file has numeric data and text.
VBBV
VBBV 2020 年 12 月 1 日
You can delete those if you want after importing to matlab workspace

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

回答 (1 件)

Rishik Ramena
Rishik Ramena 2020 年 12 月 4 日
You can process the NaNs after importing them to MATLAB. This link might be helpful.

カテゴリ

Help Center および File ExchangeIntroduction to Installation and Licensing についてさらに検索

タグ

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by