How to build x and y coordinates using a For loop

조회 수: 4 (최근 30일)
leydy Garcia
leydy Garcia 2020년 2월 20일
댓글: leydy Garcia 2020년 2월 20일
Hi. I want to plot a series of lines using x and y data extracted from a uitable. But I am having some error regarding the dimension of x and y. Here is the code:
x1=zeros(12,1);
x2=zeros(12,1);
y1=zeros(12,1);
y2=zeros(12,1);
x=zeros(12,2);
y=zeros(12,1);
for i=1:12
x1(i)=str2double(data(i,4));
x2(i)=str2double(data(i,4));
y1(i)=str2double(data(i,2));
y2(i)=str2double(data(i,3));
x(i)=[x1(i),x2(i)];
y(i)=[y1(i),y2(i)];
l=plot(handles.axes4,x(i),y(i));
axis(handles.axes4,'ij');
end
The error is the following:
In an assignment A(I) = B, the number of elements in B and I must be the same.
Error in Loading_Well_logs>pushbutton6_Callback (line 1898)
x(i)=[x1(i),x2(i)];
Error in gui_mainfcn (line 95)
feval(varargin{:});
Error in Loading_Well_logs (line 42)
gui_mainfcn(gui_State, varargin{:});
Error in @(hObject,eventdata)Loading_Well_logs('pushbutton6_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating UIControl Callback
Could somebody tell me what I am doing wrong?

채택된 답변

Fangjun Jiang
Fangjun Jiang 2020년 2월 20일
편집: Fangjun Jiang 2020년 2월 20일
maybe it should be
y=zeros(12,2)
x(i,:)=[x1(i),x2(i)];
y(i,:)=[y1(i),y2(i)];

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Programming에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by