output table with different variable lengths

4 visualizaciones (últimos 30 días)
Jocelyn
Jocelyn el 9 de En. de 2021
Respondida: Walter Roberson el 9 de En. de 2021
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')

Respuesta aceptada

Walter Roberson
Walter Roberson el 9 de En. de 2021
Use gradient() instead of your current diff() based system. The output will be the same size as the input.

Más respuestas (0)

Categorías

Más información sobre Tables en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by