フィルターのクリア

How can I get my table to display a value instead of a symbol?

3 ビュー (過去 30 日間)
Erin Winkler
Erin Winkler 2018 年 5 月 31 日
回答済み: Steven Lord 2018 年 5 月 31 日
Hi all,
I have a table of different analysis methods and I'm trying to output the results in a table.
I have the confidence bands for one method done and stored the mean of the upper and lower limits (mean over 1000 samples so just a single number) as a variable. In my table, I call to display that single 8 byte value and instead, if shows a weird symbol that looks like half of a ceiling symbol. When I check that I wrote the table correctly and that the value I called in the table are correct and the value is a single number, it checks out. But the table won't display it? I attached what the table looks like as a JPG. Here is the code for the table:
True = [betaTrueW,betaTrueW,betaTrueW];
RowNames = {'Beta MLE','Beta Median Rank Regression 1 (y on x)','Beta Median Rank Regression 2 (x on y)'};
Mean = [betaMLEmeanC, betaMRmeanC, betaMR2meanC];
Low = [blMLEC, '-','-'];
Up = [buMLEC, '-','-'];
SD = [betaMLEsdC, betaMRsdC, betaMR2sdC];
Bias = [betaMLEbiasC, betaMRbiasC, betaMR2biasC];
MSE = [betaMLEmseC, betaMRmseC, betaMR2mseC];
T3C = table;
T3C.Estimator_Method_Option_C = RowNames';
T3C.TrueBeta = True';
T3C.Mean = Mean';
T3C.Confidence_Low = Low';
T3C.Confidence_Up = Up';
T3C.SD = SD';
T3C.Bias = Bias';
T3C.MSE = MSE';
and blMLEC = 1.5945 and buMLEC = 2.4565.
Any thoughts?

採用された回答

Steven Lord
Steven Lord 2018 年 5 月 31 日
When you run the following line of code, the variable blMLEC contains a double value.
Low = [blMLEC, '-','-'];
By this table in the documentation, when you combine a double and a char vector in one array, the result is a char array.
What is char(1.5945)? It's not the vector '1.5945' (the string class has that behavior and would return the string "1.5945", but the char class does not.) It's a control character.
If you want to combine text data and numeric data into one text data with the textual representation of the number, use the string class or use num2str.
>> 1.5945 + "-" + "-"
ans =
"1.5945--"
>> [num2str(1.5945), '-' ,'-']
ans =
'1.5945--'
>> [1.5945 "-" "-"]
ans =
1×3 string array
"1.5945" "-" "-"
But looking at your use case, you probably don't want to convert the number into text data. Instead, fill the elements of your Low vector where you don't have data with missing or NaN.
>> Low = [1.5945 missing missing]
Low =
1.5945 NaN NaN
>> Low = [1.5945 NaN NaN]
Low =
1.5945 NaN NaN
Now when you want to process your data, there are functions specifically defined for working with missing data or that can "do the right thing" when working on a set of data that contains missing data.
>> min(Low, [], 'omitnan')

その他の回答 (0 件)

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by