How do I make it calculate the variable maxK inbetween both input arguments?

How do I make it calculate the variable maxK in between both input arguments:
clear;
close all;
clc;
N = input('Gamemode [4/5/6+]: ');
maxK = (N^2 + 5*N + 6) / 2; % <======= This variable, so it can be used in the K input request
K = input(['Starting pieces [max.' maxK ']: ']);

 採用された回答

Kamil Antos
Kamil Antos 2019 年 12 月 16 日
input([sprintf('Starting pieces [max.%i]: ', maxK)])

その他の回答 (1 件)

Steven Lord
Steven Lord 2019 年 12 月 16 日
If you're using release R2016b or later of MATLAB, you can use string. If you're using release R2017a or later you can define the string arrays that make up most of your message using double quotes.
K = input("Starting pieces [max." + maxK + "]: ");

カテゴリ

ヘルプ センター および File ExchangeDescriptive Statistics についてさらに検索

質問済み:

2019 年 12 月 16 日

回答済み:

2019 年 12 月 16 日

Community Treasure Hunt

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

Start Hunting!

Translated by