필터 지우기
필터 지우기

Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

Making a legend from a cell array

조회 수: 1 (최근 30일)
Eliah Verbeemen
Eliah Verbeemen 2018년 5월 22일
마감: Eliah Verbeemen 2018년 5월 23일
I have a cell array with an unknown amount of numbers in. I used the following code to make a legend. Can someone please tell me why only the first graph has a legend?
str = ('');
komma = (',');
for dd= 1:z
str= strjoin (num{1,dd},str);
if dd<z
str = {str};
str = strjoin(str,komma);
else
end
end
end

답변 (1개)

Ameer Hamza
Ameer Hamza 2018년 5월 22일
You are trying to join all the character into one variable. For legend, you need to create a cell array. If you want to create multiple legends from numbers, create them like this
z = 5;
str = num2cell(repmat(' ', 1, z));
for dd= 1:5
str{dd}= num2str(dd);
end
Then use
legend(str)
to add the legend to the figure.

이 질문은 마감되었습니다.

태그

Community Treasure Hunt

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

Start Hunting!

Translated by