Multiplying cell with a function call

3 vues (au cours des 30 derniers jours)
Durlov Rahman
Durlov Rahman le 2 Juil 2021
Commenté : Jonas le 3 Juil 2021
Hi, I am facing a problem. It is being described below:
function [ryz] = ryz(a)
ryz= [(cosd(a))^2 -(cosd(a)*sind(a)) -sind(a);
sind(a) cosd(a) 0;
cosd(a)*sind(a) -(sind(a)*sind(a)) cosd(a)];
end
A= [1:6]
[m n] = size(A)
q =floor(n/3)
trips = cell(1, q+1)
for i=1:q
trips{i} = A(:,3*(i-1)+1:3*(i-1)+3);
end
**** Here a cell named trips is being produced. trips = {1 2 3}, {4 5 6} *****
d1 = cell(360,1)
for angle = 1:360
d1{angle} = trips * ryz(angle)
end
But Now an error occurs.
Operator ' * ' is not supported for operands of type 'cell'.
Error in (line 15)
d1{angle} = trips * ryz(angle)
How can I solve this error?

Réponses (1)

Jonas
Jonas le 2 Juil 2021
trips is a cell array where each cells contains doibles you created earlier. if you want to calculate something with the content of a cell use e.g. trips{1}
  2 commentaires
Durlov Rahman
Durlov Rahman le 2 Juil 2021
Modifié(e) : Durlov Rahman le 2 Juil 2021
I know that. trips{1} trips{2} can be used. But I don’t want to use every double elements manually. I just want to use all the elements of trips cell to multiply with the function just by a single call.
Jonas
Jonas le 3 Juil 2021
then tell us what exactly your desired output for one iteration of the for loop is.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Operators and Elementary Operations dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by