how to export data with writetable?
Show older comments
i wanna export whole output in 1 sheet and i wanna know how to export it in separated sheets...
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);
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];
Tm=table(outputData(:,1,i),outputData(:,2,i),'VariableNames',{'a','b',});
disp(Tm);
writetable(Tm, 'C:\Users\arian\Desktop/generate sigma.xls' , 'Sheet', 1);
loglog(outputData(:,1,i), outputData(:,2,i), 'DisplayName', sprintf('Generated Data Set %d', i));
end
% Display the generated data for each set
% figure
hold on
for i = 1:numSets
disp(['Generated Data Set ', num2str(i)]);
%disp(outputData(:,:,i));
%figure(i)
plot(outputData(:,1,i), outputData(:,2,i), 'DisplayName',["Generated Data Set "+i])
end
hold off
grid
legend('Location','best')
Accepted Answer
More Answers (0)
Categories
Find more on Logical in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!