필터 지우기
필터 지우기

How to pass an cell array as input to a function

조회 수: 4 (최근 30일)
Gova ReDDy
Gova ReDDy 2014년 1월 14일
답변: Tyler Cushman 2017년 12월 10일
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".

채택된 답변

Mischa Kim
Mischa Kim 2014년 1월 14일
편집: Mischa Kim 2014년 1월 14일
Remove the {a} in the function input: shift_and_Average(a,needed,p5,p4,p3,p2)

추가 답변 (2개)

Azzi Abdelmalek
Azzi Abdelmalek 2014년 1월 14일
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;

Tyler Cushman
Tyler Cushman 2017년 12월 10일
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.

카테고리

Help CenterFile Exchange에서 Multidimensional Arrays에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by