フィルターのクリア

How do I stop strings in matrices from displaying as NaN when using disp()?

7 ビュー (過去 30 日間)
Edoardo Modestini
Edoardo Modestini 2023 年 5 月 1 日
回答済み: Walter Roberson 2023 年 5 月 1 日
Hi,
I'm trying to get my function to output arrays where the first element is a string giving the stage number, and the rest of the elements are the variables for this stage. However, when displaying this, it seems to display "NaN" instead of the string I have set as the first character. Would anyone know how to fix this? Thanks in advance.
perm_f = calc_perm(stage_frac, k);
perm_flow = perm_f*ratio*stage_total;
global permeates;
global rejects;
perm_string = "STAGE " + string(count) + " permeate";
perm_for_table(2:length(perm_flow)+1) = perm_flow;
perm_for_table(1) = perm_string;
perm_for_table = transpose(perm_for_table);
rej_string = "STAGE " + string(count) + " reject";
rej_for_table(2:length(rej_flow)+1) = rej_flow;
rej_for_table(1) = rej_string;
rej_for_table = transpose(rej_for_table);
%permeates = [permeates, perm_for_table];
%rejects = [rejects, rej_for_table];
  2 件のコメント
Walter Roberson
Walter Roberson 2023 年 5 月 1 日
rej_flow is not defined in the code, so we do not know its datatype.
I predict that it is a numeric data type.
Edoardo Modestini
Edoardo Modestini 2023 年 5 月 1 日
Hi, yes, it is a numeric data type. How would I go about fixing this in that case?

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

回答 (1 件)

Walter Roberson
Walter Roberson 2023 年 5 月 1 日
perm_f = calc_perm(stage_frac, k);
perm_flow = perm_f*ratio*stage_total;
global permeates;
global rejects;
perm_string = "STAGE " + string(count) + " permeate";
perm_for_table(2:length(perm_flow)+1) = perm_flow;
perm_for_table(1) = perm_string;
perm_for_table = transpose(perm_for_table);
rej_string = "STAGE " + string(count) + " reject";
rej_for_table(2:length(rej_flow)+1) = string(rej_flow);
rej_for_table(1) = rej_string;
rej_for_table = transpose(rej_for_table);
%permeates = [permeates, perm_for_table];
%rejects = [rejects, rej_for_table];

カテゴリ

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

タグ

製品


リリース

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by