How do I set all variables as zero or null?

32 ビュー (過去 30 日間)
AbdullahMZ
AbdullahMZ 2019 年 11 月 9 日
回答済み: Walter Roberson 2019 年 11 月 9 日
Hi everyone,
I am trying to find a way to begin my script by setting all the variables as zero, and then the script will start changing the variables as I go along?
any way I can do that? any function like the Python function :
Fillna(0,inplace=True);
Thank you
  2 件のコメント
per isakson
per isakson 2019 年 11 月 9 日
編集済み: per isakson 2019 年 11 月 9 日
Yes
x = zeros( number_of_rows, number_of_columns );
or (imo better)
x = nan( number_of_rows, number_of_columns );
AbdullahMZ
AbdullahMZ 2019 年 11 月 9 日
this function will only pre-define variable x, I want to pre-define all the variables

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

回答 (1 件)

Walter Roberson
Walter Roberson 2019 年 11 月 9 日
No, there is no way to tell MATLAB that all variables it encounters should be considered to be initialized to zero.
There are ways to list off a number of variables by name and tell MATLAB to initialize them all to zero, but those ways are not recommended
In python, fillna() is a method for Pandas dataframes that changes nan values into other values. The MATLAB equivalent is fillmissing() . However, that has nothing to do with setting all variables to zero at the beginning.

カテゴリ

Help Center および File ExchangeCall Python from MATLAB についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by