What does this error mean: "Assigning to 3 elements using a simple assignment statement is not supported. Consider using comma-separated list assignment." How to remove?

233 次查看(过去 30 天)
I am trying to create a clustered bar graph from this data.
times = [5,20,40,60,120];
ravgdm =
35.3689 34.2453 31.9268 29.3701 33.5380
30.4708 32.3411 28.3500 27.8087 28.9000
19.7406 21.9029 20.6332 18.9298 20.4248
My code looks like this.
figure()
times = [5,20,40,60,120];
bcv = bar(times,ravgdm)
bcv.FaceColor = 'flat';
bcv.CData(1,:) = [0.9290, 0.6940, 0.1250];
bcv.CData(2,:) = [0.4940, 0.1840, 0.5560];
bcv.CData(3,:) = [0.9, 0.1, 0.1];
set(gca, 'XTickLabel', {'5','20','40','60', '120'})
xlabel ('Time (min)')
ylabel ('Average Diameter (pixels)')
title ('Average Diameter (pixels) at Each Time Point')
However, I keep getting theses errors, and I dont know why.
Assigning to 3 elements using a simple assignment statement is not supported. Consider using
comma-separated list assignment.
Error in csize (line 64)
bcv.FaceColor = 'flat';
Some insight on why this is occuring would be great! Thank you!
  2 个评论
Chinmayee L M
Chinmayee L M 2023-12-9
移动:Voss 2023-12-9
I have a related issue.
a = [10;2;0;0;0;2;6;7];
b = [0;8;1;0;0;4;2;3];
c = [0;0;9;10;10;4;2;0];
x = [2; 2.5; 3; 3.5; 3.75; 4; 4.5; 5];
r1 = ribbon(x, [a b c]);
This gives me 3 ribbons.
I want to change the appearence of all the 3 together. For example, I want the FaceAlpha to be 0.5
I can do this:
r1(1).FaceAlpha = 0.5
r1 =
3×1 Surface array: Surface Surface Surface
r1(2).FaceAlpha = 0.5
r1 =
3×1 Surface array: Surface Surface Surface
If I write
r1(1:3).FaceAlpha = 0.5
Assigning to 3 elements using a simple assignment statement is not supported. Consider using comma-separated list assignment.
I get this error:
Assigning to 3 elements using a simple assignment statement is not supported. Consider using comma-separated list assignment.
What is the right way to access all the ribbons together?

请先登录,再进行评论。

采纳的回答

Star Strider
Star Strider 2022-4-12
There was a minor problem with indexing into the ‘bcv’ handle.
Try something like this —
times = [5,20,40,60,120];
ravgdm = [...
35.3689 34.2453 31.9268 29.3701 33.5380
30.4708 32.3411 28.3500 27.8087 28.9000
19.7406 21.9029 20.6332 18.9298 20.4248];
% My code looks like this.
figure()
times = [5,20,40,60,120];
bcv = bar(times,ravgdm, 'FaceColor','flat');
% bcv.FaceColor = 'flat';
bcv(1).CData = [0.9290, 0.6940, 0.1250];
bcv(2).CData = [0.4940, 0.1840, 0.5560];
bcv(3).CData = [0.9, 0.1, 0.1];
set(gca, 'XTickLabel', {'5','20','40','60', '120'})
xlabel ('Time (min)')
ylabel ('Average Diameter (pixels)')
title ('Average Diameter (pixels) at Each Time Point')
.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Discrete Data Plots 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by