for x = 1:100
for y = 1:61
b = abs(bsxfun(@minus,q{x},kevin))
s{x,y} = b;
end
end
How do I incorporate the above code as function?
the variables kevin and q are already loaded on the workspace.
thanks

 채택된 답변

Azzi Abdelmalek
Azzi Abdelmalek 2014년 12월 21일
편집: Azzi Abdelmalek 2014년 12월 21일

0 개 추천

function s=yourfunction(q,kevin)
for x = 1:100
for y = 1:61
b = abs(bsxfun(@minus,q{x},kevin))
s{x,y} = b;
end
end
save this file as yourfunction.m
To call this function
q= % assign value to q
kevin= % assign value to kevin
s=yourfunction(q,kevin)

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

태그

질문:

AA
2014년 12월 21일

편집:

2014년 12월 21일

Community Treasure Hunt

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

Start Hunting!

Translated by