Logical and function question.

3 ビュー (過去 30 日間)
Danny C
Danny C 2016 年 9 月 16 日
コメント済み: John D'Errico 2016 年 9 月 16 日
I'm trying to create a function that satisfies the following conditions :
- There must be more letters than numbers in combination.
- There must be at least one uppercase letter.
- The summation of all numeric digits must be between the given minimal and maximal values (exclusive).
And the following is the input I put in. (originalcombo, mincombo, maxcombo) and the output is supposed to be 'true'(1) but it keeps giving me the answer that it's false(0). How can I fix this problem?
originalcombo = 'GPBurdell1885';
mincombo = 20;
maxcombo = 30;
numbercombo=str2double(regexp(originalcombo,'[\d.]+','match'));
W=str2double(regexp(num2str(numbercombo),'\d','match'));
numberoutput = sum(numbercombo);
B = length(originalcombo);
C = B - length(numbercombo);
A = isstrprop(originalcombo, 'upper');
A = sum(A);
lock = (C > length(W)) && (A > 0) && (maxcombo>numberoutput>mincombo)
  2 件のコメント
Walter Roberson
Walter Roberson 2016 年 9 月 16 日
編集済み: Walter Roberson 2016 年 9 月 16 日
I would point out that the numeric digits are not necessarily going to be beside each other, and that the digits are to be added individually. I would also point out that '.' should not be included as a numeric digit.
John D'Errico
John D'Errico 2016 年 9 月 16 日
You just asked this question. So why post a second question just to provide more information?????????
Add a comment (NOT a new question, NOT an answer.) Or edit your original question.

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

回答 (0 件)

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by