Filter löschen
Filter löschen

how to put each element of vector as a label for the plot

12 Ansichten (letzte 30 Tage)
NA
NA am 23 Mär. 2022
Beantwortet: Chunru am 23 Mär. 2022
I have vector A as
A = [69; 70; 74; 77; 118; 103; 104];
I want to put each element of A vector as a label for the plot. Instead of using this one
h = boxplot(x,'Labels',{'69'; '70'; '74'; '77'; '118'; '103'; '104'});
I want to use something just like this
chr_A = string(A)
h = boxplot(x,'Labels',{chr_A});
this is the error I got
Caused by:
Error using cell
Conversion to cell from string is not possible.
  1 Kommentar
AndresVar
AndresVar am 23 Mär. 2022
like this?
A = [69; 70; 74; 77; 118; 103; 104]; % for example
x = rand(numel(A));
h = boxplot(x,'Labels',string(A));

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Chunru
Chunru am 23 Mär. 2022
x = randn(5, 7);
A = [69; 70; 74; 77; 118; 103; 104];
% Just use the string array instead of cell
chr_A = string(A);
h = boxplot(x,'Labels',chr_A);

Weitere Antworten (0)

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by