필터 지우기
필터 지우기

Need help setting up a for loop for the below code

조회 수: 1 (최근 30일)
Kevin Akash Rajasekaran
Kevin Akash Rajasekaran 2021년 6월 5일
댓글: Kevin Akash Rajasekaran 2021년 6월 5일
Hey all! I'm working on a project in which I have to construct fixation maps on a number of trials in an experiment. In the following piece of code, the various trials are given by condIds.
[conds,condIds] = d.getConds();
myTrials = find(condIds == condIds(2));
map = d.mkSaliencyMap(myTrials);
As you can see there, I can specify the trial I want to construct the map for by specifying the condId. Is there a way to automate the process for all such condIds? Additionally the latter part of the code, saves the map after construction as follows
map_mean = mean(map,3);
Will I be able to construct a map for each condId, save the map_mean under separate .mat files in a loop? Thanks in advance!

채택된 답변

Walter Roberson
Walter Roberson 2021년 6월 5일
  댓글 수: 3
Walter Roberson
Walter Roberson 2021년 6월 5일
[conds,condIds] = d.getConds();
G = findgroups(condIds);
map_results = splitapply(@handle_a_map, d.mkSaliencyMap, G);
where handle_a_map is a function that you write that does whatever is appropriate to your map variable.
Your function can return a cell array if you need to return multiple values.
Kevin Akash Rajasekaran
Kevin Akash Rajasekaran 2021년 6월 5일
Thank you again!

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

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by