필터 지우기
필터 지우기

output table with different variable lengths

조회 수: 3 (최근 30일)
Jocelyn
Jocelyn 2021년 1월 9일
답변: Walter Roberson 2021년 1월 9일
Hello,
I would like to output the following variables into one table within excel.
Variables:
DivPar_x
DivPar_y
phata_values
When I run my code I can only get it to work when I do not include the 'phata_values' when creating the table (as written in code below).
I think it will not work when I add the 'phata_values' into the table because it shows that it has 334 columns of data; where as the DivPar_x and DivPar_y both have 336 columns of data. Is this where the error could be coming from? If so, how do I make it so the three variables can be the same size of array lengths [1 x 336]
Secondly,
Is there a way to re-configure the table so it is not printing: 1 row and 336 columns but 1 column and 336 rows?
Thank you for your assistance!
% to get phata need to take derivative
phata2_Y_diverging = diff(Y_2);
phata2_X_diverging = diff(x_b);
phata3_Y_parabala = diff(Y_3);
phata3_X_parabala = diff(X_3);
% create table to output to excel
DivPar_x =[x_b, X_3]; % [1 x 336 double]
DivPar_y = [Y_2, Y_3]; % [1 x 336 double]
phata_values = [phataY./phataX]; % [1 x 334]
T = table([DivPar_x; DivPar_y])
%% T = table([DivPar_x; DivPar_y; phata_values]) --> produces an error / will not output to excel
writetable(T, 'test2.xlsx')

채택된 답변

Walter Roberson
Walter Roberson 2021년 1월 9일
Use gradient() instead of your current diff() based system. The output will be the same size as the input.

추가 답변 (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