필터 지우기
필터 지우기

how to access element of map when I don't know unique keys?

조회 수: 1 (최근 30일)
Võ Kiet
Võ Kiet 2021년 8월 10일
댓글: Võ Kiet 2021년 8월 22일
Hi everybody,
I have problem with this function below. Please help me!!!
Code:
%keySet and valueSet is input
keySet = {'Jan','Feb','Mar','Apr'};
valueSet = [327.2 368.2 197.6 178.4];
function [output] = Dosomething(keySet,valueSet)
M = containers.Map(keySet,valueSet);
% In this function, how to access element of M when I don't know 'keySet' value?
if M('Jan') == 327.2
disp('correct')
end
end
I mean, when I make this function, I'm going to pass non-fixed arguments into this function, so how do I pass in a function that can map the pairs of parameters to each other so that I can utilize them?
Thanks and Best Regards,
Kiet Vo

채택된 답변

Wan Ji
Wan Ji 2021년 8월 20일
You can get keys and values by
keys = M.keys;
values = M.values;
  댓글 수: 1
Võ Kiet
Võ Kiet 2021년 8월 22일
First, I'm sorry because reply too late (Because I miss the message). Thanks so much for your supports, my friend =v=

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Array Geometries and Analysis에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by