how to add string values into an array

1 回表示 (過去 30 日間)
umut
umut 2018 年 4 月 13 日
コメント済み: umut 2018 年 4 月 13 日
I'm classification on two images and I want to store the returned string values in an array. function returns a string to be displayed on the screen as the return value and this array is a 1x1 cell matrix. how do I hold all return values in a single array and print them on the screen?
img = imread('aaa.jpg');
[labelIdx, scores] = predict(categoryClassifier, img);
% Display the string label
categoryClassifier.Labels(labelIdx)
img1 = imread('rr.jpg');
[labelIdx, scores1] = predict(categoryClassifier, img1);
% Display the string label
x=categoryClassifier.Labels(labelIdx)
and this is output:
ans =
cell
'airplanes'
x =
cell
'airplanes'
workspace looks like this I have two separate matriX BUT I do not want it how can i hold the "airplane" strings in same matrix?
  2 件のコメント
Dennis
Dennis 2018 年 4 月 13 日
img = imread('aaa.jpg');
[labelIdx, scores] = predict(categoryClassifier, img);
% Display the string label
x{1}=categoryClassifier.Labels(labelIdx)
img1 = imread('rr.jpg');
[labelIdx, scores1] = predict(categoryClassifier, img1);
% Display the string label
x{2}=categoryClassifier.Labels(labelIdx)
umut
umut 2018 年 4 月 13 日
Firstly, thank you for your reply yes it's work but it gives different output in console screen.
This is console screen output:
cell
{1×1 cell}
x =
1×2 cell array
{1×1 cell} {1×1 cell}

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

採用された回答

Stephen23
Stephen23 2018 年 4 月 13 日
編集済み: Stephen23 2018 年 4 月 13 日
Use parentheses to save the outputs into one cell array:
x(1) = categoryClassifier...
...
x(2) = categoryClassifier...
As long as the outputs are both scalar cell arrays then this will give a 1x2 cell array. If the outputs are different classes of are non-scalar then this will not work.
  1 件のコメント
umut
umut 2018 年 4 月 13 日
yes it's working thank u

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

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by