MATLAB-Basics

MATLAB Exercise Array Multiplication Matrices must have the same dimensions Dimensions of resulting matrix = dimensions of multiplied matrices Resulting elements = product of corresponding elements from the original matrices Same rules apply for other array operations a = [1 2 3 4; 5 6 7 8]; b = [1:4; 1:4]; c = a.*b c = 1 4 9 16 5 12 21 32 c(2,4) = a(2,4)*b(2,4) bal = 15000 * rand; if bal 5000 rate = 0.09; elseif bal 10000 rate = 0.12; else rate = 0.15; end newbal = bal + rate + bal; disp(’New balance is: ’) disp(newbal) Deciding with if for in

文档评论(0)

1亿VIP精品文档

相关文档