writematrix not working matlab

11 ビュー (過去 30 日間)
Anderco Iosif Tiberiu
Anderco Iosif Tiberiu 2021 年 5 月 19 日
編集済み: Image Analyst 2021 年 5 月 19 日
Hi, I am trying to write to a .xlsx file like this
val = [id, title, category, number];
writematrix(val, 'carti.xlsx', 'WriteMode','append');
I get the values from editfields
id and number are int and title and category are strings
my problem is that this function will write to all the data to de A row instead of the A, B, C, and D row.
  3 件のコメント
Anderco Iosif Tiberiu
Anderco Iosif Tiberiu 2021 年 5 月 19 日
@Stephen Cobeldick I have updated the question
Image Analyst
Image Analyst 2021 年 5 月 19 日
編集済み: Image Analyst 2021 年 5 月 19 日
You added the flag "dumb question". Do you want me to delete this question? If not, attach your variables in a .mat file
save('answers.mat', 'id', 'title', 'category', 'number', 'val');

サインインしてコメントする。

回答 (1 件)

Image Analyst
Image Analyst 2021 年 5 月 19 日
But you didn't update your question to give the sizes of the arrays like Stephen asked. My suspicion is that your vectors id, title, category, number are all row vectors, not column vectors, so val is a row vector, not a matrix. Try
val = [id(:), title(:), category(:), number(:)];
That turns them all into column vectors so you'll have an N row-by-4 column matrix and now you should see that in the workbook instead of having them all on the same line.
  1 件のコメント
Anderco Iosif Tiberiu
Anderco Iosif Tiberiu 2021 年 5 月 19 日
they are not vectors they are variables like id = 1 tible = "abcd" category = "efgh" numer = 4

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeWorkspace Variables and MAT Files についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by