Import excel text and number, and assign

7 ビュー (過去 30 日間)
Zavier Chng
Zavier Chng 2020 年 8 月 5 日
コメント済み: Walter Roberson 2020 年 8 月 5 日
Hi all,
If my excel file have contains 6 rows and 2 column which contains text and numeric number, as shown below
X1 7
X2 5
Y1 4
Y2 3
Z1 2
Z2 3
how can i xlsread them and most importantly assign X1 = 7, X2 = 5...........Z2 = 3
Subsequently, i could perform boolean operation X1 * X2 and that will give me 35.
The reason is because i have a lot variables. around 100 +.
  3 件のコメント
Zavier Chng
Zavier Chng 2020 年 8 月 5 日
The biggest concern is there are too many variables and this variables will change for different simulation that im planning to run. That why i need a neater way to keep track of it.
Walter Roberson
Walter Roberson 2020 年 8 月 5 日
What you are proposing will not allow you to keep track.
Suppose that you read n a file that contains X1 but not X2, then what is your code to when you write X1*X2 since you assumed that X2 was present?
If you can assume that particular variables are present, then assign those.
For example you can use cell2struct() to create a struct(), and then you can examine the fieldnames() of the struct

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

回答 (0 件)

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by