How to pass an cell array as input to a function
4 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Gova ReDDy
le 14 Jan 2014
Réponse apportée : Tyler Cushman
le 10 Déc 2017
Hi, Can I know how to pass a cell array as input to a function as shown below
function [averagedSignal]=shift_and_Average(a,needed{a},p5,p4,p3,p2)
if (a==1)
p5=needed{a};
elseif(a==2)
p4=needed{a};
elseif(a==3)
p3=needed{3};
elseif(a==4)
p2=needed{4};
else
p1=p1;
The above usage is giving error like "Unbalanced or unexpected parenthesis or bracket".
0 commentaires
Réponse acceptée
Mischa Kim
le 14 Jan 2014
Modifié(e) : Mischa Kim
le 14 Jan 2014
Remove the {a} in the function input: shift_and_Average(a,needed,p5,p4,p3,p2)
0 commentaires
Plus de réponses (2)
Azzi Abdelmalek
le 14 Jan 2014
If needed represent an array
function [averagedSignal]=shift_and_Average(a,needed,p5,p4,p3,p2)
if (a==1)
p5=needed{a};
elseif(a==2)
p4=needed{a};
elseif(a==3)
p3=needed{3};
elseif(a==4)
p2=needed{4};
else
p1=p1;
0 commentaires
Tyler Cushman
le 10 Déc 2017
When I try to do this it just says undefined function for input arguments of type cell, however when I take it out of the function and just paste the code into what I want to use it on it works.
0 commentaires
Voir également
Catégories
En savoir plus sur Multidimensional Arrays dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!