Compute two matices without using the matrix multiplication
1 回表示 (過去 30 日間)
古いコメントを表示
Mansour Al Asais
2020 年 4 月 25 日
コメント済み: Mrutyunjaya Hiremath
2020 年 4 月 25 日
Hello, the title is the question and here is my code so far but I don't think it's right:
a=input('Enter a: ');
b=input('Enter b: ');
C=[];
for i=1:length(a)
for d=1:length(b)
C(i,d)=a(i).*b(d);
end
end
0 件のコメント
採用された回答
Sriram Tadavarty
2020 年 4 月 25 日
Hi Mansour,
Here is the modifications that is required for the code: (Placed a static a and b values, replace with those in your code)
a = [1 2 3; 4 5 6];
b = [1 2 3 5;6 7 8 9;10 11 12 13];
if size(a,2) ~= size(b,1)
error("Matrix multiplication is not possible.");
end
c = zeros(size(a,1),size(b,2));
for i = 1:size(a,1)
for j = 1:size(b,2)
c(i,j) = a(i,:)*b(:,j);
end
end
Hope this helps.
Regards,
Sriram
3 件のコメント
Sriram Tadavarty
2020 年 4 月 25 日
Hi,
Either way is possible. It depends on the MATLAB version you are using. From R2017a or above, strings are supported.
You can always go with character array too.
Hope this helps.
Regards,
Sriram
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Title についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!