フィルターのクリア

How to solve this problem?

2 ビュー (過去 30 日間)
Arpita
Arpita 2024 年 3 月 6 日
コメント済み: Voss 2024 年 3 月 7 日
Suppose I have an array that is a large m x n matrix. For a value y, if the numbers in this matrix are less than y, then i want to replace those values with 0, otherwise they are 1. how to compute this? I have written a rudimentary code, but i need help.
df = xlsread("Book1.xlsx");
for i = 1:448 %448 = number of columns
x = df(:,i)
if x < 40
x = 0
else
x = 1
i = i + 1
end
end

回答 (1 件)

Voss
Voss 2024 年 3 月 6 日
y = 0.3;
df = rand(3,4) % random matrix
df = 3×4
0.0521 0.9094 0.8965 0.7698 0.1742 0.3911 0.7067 0.1376 0.8626 0.0311 0.2910 0.0843
df = double(df >= y)
df = 3×4
0 1 1 1 0 1 1 0 1 0 0 0
  3 件のコメント
Arpita
Arpita 2024 年 3 月 7 日
thank you that was very helpful
Voss
Voss 2024 年 3 月 7 日
You're welcome! Any questions, let me know. Otherwise, please "Accept" this answer. Thanks!

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

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by