how to build array using matlab.graphics.chart.primitive.Line' property
조회 수: 4 (최근 30일)
이전 댓글 표시
Look this example:
selected = findobj(allLines,'Type','line','LineWidth',0.5);
[cc]=selected;
selected 13x1
xx selected 13x1
this is ok
now i try to use selected property:
selected.Color
it give me 13x1 color!
now i try to record information in array but it's not possible
[cc]=selected.Color
now i see cc have only the first element!
can i do it?
댓글 수: 0
채택된 답변
Cris LaPierre
2025년 6월 7일
편집: Cris LaPierre
2025년 6월 7일
If I understand correctly, you want cc to just be the color of the selected lines. In that case, note that selected.Color does not return a 13x1 array, It returns 13 1x3 arrays. Try the following instead.
z = rand(10,13);
plot(z)
selected = findobj(gcf,'Type','line','LineWidth',0.5);
cc=selected
cc=vertcat(selected.Color)
You can find a longer explanation of what is happening here: https://www.mathworks.com/matlabcentral/answers/29190-property-access-of-objects-arrays
댓글 수: 5
Walter Roberson
2025년 6월 8일
z = rand(10,13);
plot(z)
selected = findobj(gcf,'Type','line','LineWidth',0.5);
set(selected, {'Color'}, cellfun(@(C) {[C,0.5]}, {selected.Color}.'))
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Standard File Formats에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!