필터 지우기
필터 지우기

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?
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 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