Divide each element of an array by the corresponding element of another array

28 次查看(过去 30 天)
I have 2 cell arrays of numbers, e.g.:
a = [1, 2, 3]
b = [4, 5, 6]
and I want to divide each element of a by the corresponding element of b (1/4, 2/5, and 3/6). In python I used the 'zip' function to achieve this, but I'm not sure if anything similar exists in Matlab. Here is what I have done so far but this is not working:
for num = a
newnum = cell2mat(num);
output = newnum / b(num);
outputs(end+1) = output;
end
Thanks for the help guys, I'm brand new to Matlab so apologies for the code!

回答(1 个)

dpb
dpb 2021-7-29
c=a./b;
Read the "Getting Started" to get basic syntax...

类别

Help CenterFile Exchange 中查找有关 Logical 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by