MATLAB Answers

how to divide two structures?

A is a structure. B is a structure. i need to perform A/B. How to get it?

  1 Comment

Jan Simon
on 4 Mar 2013

Currently we can only guess, what the "/" operator should do for your data. Does "structure" mean STRUCT arrays? Should something happen with the fields?

2 Answers

Answer by Walter Roberson
on 4 Mar 2013

You do not. What would it even mean? What would you expect as the result of

struct('P', {5:10}, 'Q', {magic(17)}) / struct('S', {'hello'}, 'T', false(7,8), 'P', {2})



Answer by Azzi Abdelmalek
on 4 Mar 2013

C=cellfun(@(x,y) x/y,struct2cell(A),struct2cell(B),'un',0) 


Join the 15-year community celebration.

Play games and win prizes!

Learn more
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

MATLAB Academy

New to MATLAB?

Learn MATLAB today!