Is there a way to assign a value to an input string?

5 ビュー (過去 30 日間)
Brett Baxter
Brett Baxter 2020 年 9 月 27 日
コメント済み: Brett Baxter 2020 年 9 月 27 日
I was wondering if there was a way to assign a second value to an input that would actually be used in the function instead of the input value itself. Let me see if I can describe what I mean,
function [output] = fun(input)
'phrase' = 1
end
>>fun('phrase')
output = 1
What I'm trying to do is have Matlab recognize a certain input string and have it set its value to some other double value that can then be used in the function. Sort of like assigning a secret value to it that requires the input to be that specified string. I'm sorry if that doesn't make sense, I'm having a hard time finding the words for exactly what I'm trying to do. Can anyone help?
  2 件のコメント
KSSV
KSSV 2020 年 9 月 27 日
REad about switch, strcmp.
Brett Baxter
Brett Baxter 2020 年 9 月 27 日
Got it, thank you!

サインインしてコメントする。

回答 (0 件)

カテゴリ

Help Center および File ExchangeCharacters and Strings についてさらに検索

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by