フィルターのクリア

Division inside an array

2 ビュー (過去 30 日間)
Mohamed Musni
Mohamed Musni 2018 年 1 月 22 日
回答済み: Mohamed Musni 2018 年 1 月 22 日
these are the two arrays i have
fri =
1 2 3
j =
0 1 2 3 4 5 6
i want to divide each element inside fri by one value of j at once. ex : 1/0,2/0,3/0 after that 1/1,2/1/3/1 and so on.
when i perform Xij = j./fri it gives an error that matrix sizes must be equal.(logically this is wrong as i see). is there any way to perform this operation and get values? any help will be highly appreciated.

採用された回答

Stephen23
Stephen23 2018 年 1 月 22 日
>> fri = 1:3;
>> j = 0:6;
>> bsxfun(@rdivide,j(:),fri)
ans =
0.00000 0.00000 0.00000
1.00000 0.50000 0.33333
2.00000 1.00000 0.66667
3.00000 1.50000 1.00000
4.00000 2.00000 1.33333
5.00000 2.50000 1.66667
6.00000 3.00000 2.00000
  4 件のコメント
Mohamed Musni
Mohamed Musni 2018 年 1 月 22 日
accordingly i need to get a matrix with 0 and 1. if no remainder for the division output is 1 and if there is an remainder output is 0. any help i will be thankful because this is my last part of my thesis and i got bit stuck. thank you
Mohamed Musni
Mohamed Musni 2018 年 1 月 22 日
for more clear idea i attach this image

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

その他の回答 (2 件)

Pawel Jastrzebski
Pawel Jastrzebski 2018 年 1 月 22 日
fri = 1:3
j = 0:6
j = j'
result  = j./fri
  2 件のコメント
Mohamed Musni
Mohamed Musni 2018 年 1 月 22 日
i need to get a matrix with 0 and 1. if no remainder for the division output is 1 and if there is an remainder output is 0. any help i will be thankful because this is my last part of my thesis and i got bit stuck. thank you
Mohamed Musni
Mohamed Musni 2018 年 1 月 22 日
please
can guide me how to get this matrix

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


Mohamed Musni
Mohamed Musni 2018 年 1 月 22 日
BIG THANKS FOR EVERYBODY. I FIGURE OUT TO FIND 0 AND 1 MATRIX. THANK YOU SO MUCH GUYS APPRECIATE YOUR HELP :D

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by