how to use writetable for one sheet?
Mostrar comentarios más antiguos
i tried many things but still cant use writetable for one sheet...whatever i do it gives me last data only....i need all ten data in one single sheet and i need five first row to be empty i excel...
clear all
clc
inputData = [0.001 0.1;
0.003 0.1;
0.006 0.1;
0.1 0.09;
0.3 0.08;
0.5 0.07;
5 0.01;
7 0.005;
8 0.001;
10 0.0001];
numSets = 10; % Number of sets to generate
% Initialize an empty matrix to store the generated data
outputData = zeros(size(inputData, 1), 2, numSets);
% Path to the Excel file
excelFilePath = 'D:\generate_sigma.xlsx';
% Generate and write data to separate sheets
for i = 1:numSets
% Generate similar data with increasing amplitude
scalingFactor = i * 0.1;
generatedData = scalingFactor * inputData(:, 1);
sigma = scalingFactor * inputData(:, 2);
% Store the generated data in the output matrix
outputData(:,:,i) = [generatedData, sigma];
% Create a table for the generated data
Tm = table(outputData(:,1,i), outputData(:,2,i), 'VariableNames', {'a', 'b'});
% Write the table to a separate sheet in the Excel file
writetable(Tm, excelFilePath, 'Sheet', i);
% Plot the data
loglog(outputData(:,1,i), outputData(:,2,i), 'DisplayName', sprintf('Generated Data Set %d', i));
hold on; % Keep the plot hold on for the next data set
end
% Adjust plot settings
grid on;
legend('Location', 'best');
hold off; % Release the plot hold
% Display the generated data for each set
for i = 1:numSets
disp(['Generated Data Set ', num2str(i)]);
disp(outputData(:,:,i));
end
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Spreadsheets en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

