Simulink: Create line object - Matrix vs. vector input

Why is there a difference between
figure;
process = {'process' , [0.2500 0.5000], [0.6 0.8];
'process2', [0.1250 0.2500], [0.2 0.6];
'process3', [0.3125 0.2500], [0.4 0.6];
'process4', [0.2500 0.3125], [0.2 0.4];
'process5', [0.3750 0.3125], [0.2 0.4];
'process5', [0.5625 0.5000], [0.6 0.8];};
L=line(cell2mat(process(:,2)), cell2mat(process(:,3)));
and
figure;
process = {'process' , [0.2500 0.5000], [0.6 0.8];
'process2', [0.1250 0.2500], [0.2 0.6];
'process3', [0.3125 0.2500], [0.4 0.6];
'process4', [0.2500 0.3125], [0.2 0.4];
'process5', [0.3750 0.3125], [0.2 0.4];
'process5', [0.5625 0.5000], [0.6 0.8];};
hold on
L=line(cell2mat(process(1,2)), cell2mat(process(1,3)));
L=line(cell2mat(process(2,2)), cell2mat(process(2,3)));
L=line(cell2mat(process(3,2)), cell2mat(process(3,3)));
L=line(cell2mat(process(4,2)), cell2mat(process(4,3)));
L=line(cell2mat(process(5,2)), cell2mat(process(5,3)));
L=line(cell2mat(process(6,2)), cell2mat(process(6,3)));
?
Is there a way that enables me to use the first version (= using the line function only once) with the result of the second one?

 채택된 답변

Steffen Müller
Steffen Müller 2016년 3월 31일
The solution is simply to use
L=line(cell2mat(process(:,2))', cell2mat(process(:,3))');
instead of
L=line(cell2mat(process(:,2)), cell2mat(process(:,3)));

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Simulink Functions에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by