필터 지우기
필터 지우기

How to get rid of this error when adding an element to the rows of a table?

조회 수: 2 (최근 30일)
I have a table with strings and double values. When I try to add new element in each row I will get this value. Could some one explain me what can be done?
Warning: The assignment added rows to the table, but did not assign values to all of the table's existing variables. Those variables have been extended with rows containing default values. > In tabular/subsasgnDot (line 338) In tabular/subsasgn (line 67) In orderMain (line 140)
  댓글 수: 3
Pratheek Manangi
Pratheek Manangi 2017년 5월 18일
for i=1:length(rpmFixed)
DatTab.rpm(i,1)=rpmFixed(i);
DatTab.Lss1(i,1)=orderNewSlices{1,1}(1,i);
DatTab.Lss2(i,1)=orderNewSlices{1,2}(1,i);
DatTab.Lss3(i,1)=orderNewSlices{1,3}(1,i);
DatTab.Lss4(i,1)=orderNewSlices{1,4}(1,i);
DatTab.Lss5(i,1)=orderNewSlices{1,5}(1,i);
DatTab.Lss6(i,1)=orderNewSlices{1,6}(1,i);
DatTab.Lss7(i,1)=orderNewSlices{1,7}(1,i);
DatTab.Lss8(i,1)=orderNewSlices{1,8}(1,i);
DatTab.Lss9(i,1)=orderNewSlices{1,9}(1,i);
DatTab.Lss10(i,1)=orderNewSlices{1,10}(1,i);
DatTab.IMS1(i,1)=orderNewSlices{1,11}(1,i);
DatTab.IMS2(i,1)=orderNewSlices{1,12}(1,i);
DatTab.IMS3(i,1)=orderNewSlices{1,13}(1,i);
DatTab.HSS1(i,1)=orderNewSlices{1,14}(1,i);
DatTab.HSS2(i,1)=orderNewSlices{1,15}(1,i);
DatTab.Hss3(i,1)=orderNewSlices{1,16}(1,i);
end
Pratheek Manangi
Pratheek Manangi 2017년 5월 18일
Hello Thanks for the reply,
Here is my code. Could you suggest me what I can do to resolve that warning?

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

채택된 답변

Guillaume
Guillaume 2017년 5월 18일
You're probably using the slowest and most complicated way to create a table.
tempslices = cellfun(@ctranspose, orderNewSlices, 'UniformOutput', false); %transpose the row vectors in the cell array to column vectors
DatTab = [table(rpmFixed(:), 'VariableNames', {'rpm'}), ...
cell2table(orderNewSlices, 'VariableNames', ...
[compose('Lss%d', 1:10), compose('IMS%d', 1:3), compose('HSS%d', 1:3)])]
should do the same.
  댓글 수: 9
Guillaume
Guillaume 2017년 5월 22일
Yes, note that my latest code differs from the earlier one where I'd made a mistake. I've changed tempslices(:) to tempslices{:} (notice the different brackets), which properly passes the elements of the cell array as columns.
If that still doesn't work then check the output of:
size(rpmFixed)
%and
celldisp(cellfun(@size, tempslices, 'UniformOutput', false))

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

추가 답변 (0개)

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by