필터 지우기
필터 지우기

How to return a structure as a function output?

조회 수: 28 (최근 30일)
Anisia Anil
Anisia Anil 2022년 12월 14일
댓글: Anisia Anil 2022년 12월 14일
function [s, rx, ry] = ComputeR(frame);
[pyr,pind] = buildLpyr(frame,'auto'); %Building Laplace pyramid
nLevels = size(pind,1)-1; %no. of levels in the pyramid
kernelx = [0.0, 0.0, 0.0; 0.5, 0.0, -0.5; 0.0, 0.0, 0.0];
kernely = [0.0, 0.5, 0.0; 0.0, 0.0, 0.0; 0.0, -0.5, 0.0];
for k = 1:nLevels
s = pyrBand(pyr, pind, k);
rx = conv2(s,kernelx);
ry = conv2(s,kernely);
S(k).s = s;
S(k).rx = rx;
S(k).ry = ry;
end
end
Here this function is returning the values of s, rx, ry corresponding to the last 'k' value only. How can I get the whole values of S(k).s, S(k).rx and S(k).ry as my function output?
  댓글 수: 1
Jiri Hajek
Jiri Hajek 2022년 12월 14일
Hi, you need just one output, the structure itself. Its field are part of it... Or try to explain better what you mean by "How can I get the whole values of S(k).s, S(k).rx and S(k).ry as my function output?"

댓글을 달려면 로그인하십시오.

채택된 답변

Rik
Rik 2022년 12월 14일
If you want the entire struct as the output, then you should make the struct the output:
function S = ComputeR(frame);

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Get Started with MATLAB에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by