MATLAB Answers

Use data in an array for 'Plot' command

조회 수: 1(최근 30일)
LR
LR 2021년 5월 13일
댓글: LR 2021년 5월 14일
I need to draw a shape using the 'Plot' command, the data is stored in an array called 'shape'. This is my attempt so far:
for i=1:1:length(shape(j,4,i))-1
plot([shape(j,4,i) shape(j,4,i+1)],[shape(j,5,i) shape(j,5,i+1)],'k');
hold on;
end
plot([shape(j,4,i))(length(shape(j,4,i)) shape(j,4,i)(1)],[shape(j,5,i)(length(shape(j,5,i))) shape(j,5,i)(1)],'k');
end
I receive this error: "Invalid expression. When calling a function or indexing a variable, use parentheses. Otherwise, check for mismatched delimiters."
Is this the correct format to use to call data from an array because I cannot see any problems with the brackets?
Thank you

답변(1개)

VBBV
VBBV 2021년 5월 13일
%if true
plot([shape(j,4,i) length(shape(j,4,i)) shape(j,4,i)(1)],[shape(j,5,i)(length(shape(j,5,i))) shape(j,5,i)(1)],'k');
Try now
  댓글 수: 5
LR
LR 2021년 5월 14일
Which For loop should I place the 'plot' code in, I've tried i and j but neither worked.

댓글을 달려면 로그인하십시오.

태그

Community Treasure Hunt

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

Start Hunting!

Translated by