please help with multiplication and division function
1 view (last 30 days)
Show older comments
A={1;2;3;4;5;6;7}; B={1;2;3;4;5;6;7};
A and B are both cell arrays, I would like to find C
C=(3*A-C)/2;
0 Comments
Answers (2)
Robert U
on 4 Jul 2018
Edited: Robert U
on 4 Jul 2018
Hi Emmanuel Akpan,
The question you raised is not clear. Taking into consideration the given equation you can find easily by manual calculation that it is satisfied for
C = A;
In case you would like to calculate
C = (3*A-B)/2;
while use of cell arrays is mandatory, there are several ways of doing that. Depending on what output format you would like to achieve you might have to alter the shown examples. I assume, output should be cell array again:
A={1;2;3;4;5;6;7};
B={1;2;3;4;5;6;7};
C1 = cellfun(@(cA,cB) (3*cA-cB)/2,A,B,'UniformOutput',false);
C2 = arrayfun(@(dIn) dIn,(3*cell2mat(A)-cell2mat(B))/2,'UniformOutput',false);
Kind regards,
Robert
See Also
Categories
Find more on Entering Commands in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!