Arithmetic division for cell array

15 vues (au cours des 30 derniers jours)
Sherif Shokry
Sherif Shokry le 20 Déc 2017
Commenté : Sherif Shokry le 20 Déc 2017
I have 2 cell arrays (same dimensions). How can I divide only the variables in the 2nd array in the 1st cell array over the 2nd array in the 2nd cell array
veh_speeds = vis.Net.Vehicles.GetMultiAttValues('Speed'); % 203x2 cell
veh_positions = vis.Net.Vehicles.GetMultiAttValues('Pos'); % 203x2 cell
  4 commentaires
James Tursa
James Tursa le 20 Déc 2017
Many of us do not want to open a pdf file. Please post text showing a small sample of cell arrays and then list exactly what you would want for a result.
Sherif Shokry
Sherif Shokry le 20 Déc 2017
veh_speeds = vis.Net.Vehicles.GetMultiAttValues('Speed'); veh_positions = vis.Net.Vehicles.GetMultiAttValues('Pos');
the result that I want: greenTime = (veh_positions(:,2))./(veh_speeds(:,2));
however the I have an error: "Undefined operator '/' for input arguments of type 'cell'."

Connectez-vous pour commenter.

Réponse acceptée

Birdman
Birdman le 20 Déc 2017
Pos=cell2mat(veh_positions(:,2));
Vel=cell2mat(veh_speeds(:,2));
Result=Pos./Vel
  1 commentaire
Sherif Shokry
Sherif Shokry le 20 Déc 2017
Thank you so much (Mr. Birdman), it works now

Connectez-vous pour commenter.

Plus de réponses (1)

Sherif Shokry
Sherif Shokry le 20 Déc 2017

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by