MATLAB中矩阵元素计算
A=[0 0 0 0 1 2 3
0 0 8 7 5 5 4]
B=[1 3 2 4 5 6 4];
C(1)=0,若A(1,j)=0,则C(1)=C(1)+0,否则,C(1)=C(1)+B(j),
若A(2,j)=0,则C(2)=C(2)+0,否则C(2)=C(2)+B(j);
最后能得出结果C=[15
21].
人气:139 ℃ 时间:2020-01-29 15:11:08
解答
B=[1 3 2 4 5 6 4];A=[0 0 0 0 1 2 3 ;0 0 8 7 5 5 4];C=zeros(1,2);for j=1:7if A(1,j)==0C(1)=C(1)+0;else C(1)=C(1)+B(j);endif A(2,j)==0C(2)=C(2)+0;else C(2)=C(2)+B(j);endend
推荐
猜你喜欢
- 有don't do sth instead of doing的用法吗,怎么翻译?
- A successful team beats with one heart是什么意思
- he often___(relax) half a day
- 用作图法求直线斜率时,必须采用什么方法?
- Edward Smith is _____old.He works in a bank.
- 连词成句 threw,Li,Ming,the,ball,another,boy,to
- Lily doesn't want to buy__same present__Lucy did填空
- 麻烦您了,您帮我看看这道题呗 we see things by our eyes对么?为什么