フィルターのクリア

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?

179 ビュー (過去 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?
Voss
Voss 2023 年 12 月 9 日
移動済み: Voss 2023 年 12 月 9 日
[r1.FaceAlpha] = deal(0.5);
Or, specifically for setting graphics objects' properties:
set(r1,'FaceAlpha',0.5);

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

採用された回答

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 Center および File ExchangeDiscrete Data Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by