Hi everyone, I am trying to build a table based on some analysis done by MATLAB, but i keep get the error: The VariableNames property must contain one name for each variable in the table. how can i fix this please. this is my code:
case_numbers=1:15;
Percentages{K}=[Percent_case1{K};Percent_case2{K};Percent_case3{K};Percent_case4{K};Percent_case5{K};Percent_case6{K};Percent_case7{K};Percent_case8{K};Percent_case9{K};Percent_case10{K};Percent_case11{K};Percent_case12{K};Percent_case13{K};Percent_case14{K};Percent_case15{K}];
n=15;
month=kron(month(K), ones(n,1));
Station=kron(Station(K), ones(n,1));
%the loop through variables to establish exel tables FOR EACH CARD:
Z={'Case_Number' 'Month' 'Card_Name' 'Percentage'};
D=[case_numbers', kron(month(K), ones(n,1)), kron(Station(K), ones(n,1)),Percentages];
filename = 'ourData3.xlsx';
W = table()..., 'VariableNames', varNames);
uc = num2cell(D, 1);
W = table(uc{:}, 'VariableNames', Z)
writetable(W,filename,'Sheet',1,'Range','D1')
x1=filename;
xtr=strcat('C:\Users\maa285\Desktop\New Folder\',x1);
fid = fopen( xtr, 'wt' );

 채택된 답변

Image Analyst
Image Analyst 2017년 12월 12일

0 개 추천

We do not have Percent_case1, etc. nor do we have 'ourData3.xlsx', which you forgot to attach, so we can't really help much. From the error message, it sounds like varNames, which you tragically forgot to include, has two or more strings with the same characters in them.

댓글 수: 3

MAHMOUD ALZIOUD
MAHMOUD ALZIOUD 2017년 12월 12일
the ourData3.xlsx is an excel file, to which i want to export data, i am trying to build a table with 4 columns mentioned in Z above, and data will come from 2 cards, each card represents a month of data, each card has 15 cases, that is why finally i will a table with 30 rows for the both cards.
Image Analyst
Image Analyst 2017년 12월 12일
OK. Good luck.
MAHMOUD ALZIOUD
MAHMOUD ALZIOUD 2017년 12월 12일
thank you

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

추가 답변 (0개)

카테고리

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

태그

질문:

2017년 12월 11일

댓글:

2017년 12월 12일

Community Treasure Hunt

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

Start Hunting!

Translated by