Matlab Legend Issue - I'm always getting legend for data1, but not for data2. Could you kindly let me know what I'm doing wrong? Thank you.
조회 수: 1 (최근 30일)
이전 댓글 표시
Stuct_1 = 1x10 struct
Stuct_2 = 1x10 struct
for i = 1:10
figure(1)
y = struct_1(i).times.*1000;
y1 = struct_0(i).times.*1000;
s0 = scatter(y,i,100,'r.');
hold on
s1 = scatter(y1,i,40,'ko');
end
legend([s0, s1], {'Data1', 'Data2'})
댓글 수: 0
채택된 답변
VBBV
2022년 11월 5일
legend([s0(1), s1(1)], {'Data1', 'Data2'})
댓글 수: 2
VBBV
2022년 11월 5일
%figure(1)
Or Comment this line and put it outside the loop at the beginning
Image Analyst
2022년 11월 5일
s0 and s1 are not vectors. They are scalars because they get overwritten on each iteration. Thus there is no need to specify (1) after them.
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Legend에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!