How to assign a row matrix to another row matrix

조회 수: 2 (최근 30일)
Andrea Sbaragli
Andrea Sbaragli 2021년 5월 11일
댓글: Andrea Sbaragli 2021년 5월 11일
This is my function:
function [T1,T2, T3] = dispatch(A)
T1 = zeros(size(A));
T2 = zeros(size(A));
T3 = zeros(size(A));
i=1;
j=1;
k=1;
z=1;
for i=1:height(A)
s=1;
if A {i,2}== 1; % tagID=1
for s=1:4
T1 (j,s) = (A(i,s));
s=s+1
end
j= j+1;
end
if A{i,2}== 2; % tagID=2
for s=1:4
T2(k,s) = A(i,s);
s=s+1
end
k= k+1;
end
if A{i,2}== 3; % tagID=3
for s=1:4
T3(z,s) = (A(i,s));
s=s+1
end
z= z+1;
end
i = i+1;
end
end
it returns me that error:
The following error occurred converting from table to double:
Undefined function 'double' for input arguments of type 'table'. To convert to numeric, use the TABLE2ARRAY function, or extract data using dot or brace subscripting.

답변 (1개)

Jan
Jan 2021년 5월 11일
편집: Jan 2021년 5월 11일
The error message suggests:
To convert to numeric, use the TABLE2ARRAY function
Did you try this already?
In one line you write:
if A {i,2}== 1
So you decided to use the brace indexing. Then you write:
T1 (j,s) = (A(i,s))
Now you try to use the parentheses. Why?
  댓글 수: 1
Andrea Sbaragli
Andrea Sbaragli 2021년 5월 11일
if A {i,2}== 1 here I used these brackets because == was not supported otherwise
T1 (j,s) = (A(i,s)) here brace index returns me the same error.
Yes I have already use table2array function but it does not work.
It is strange because inside A all values are in double format..

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

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by