Effacer les filtres
Effacer les filtres

Plotting xlsx file data using a for loop

2 vues (au cours des 30 derniers jours)
Petch Anuwutthinawin
Petch Anuwutthinawin le 27 Juin 2021
I need to plot a raw data in a xlsx file using the fit command. I need to use a for loop in order to plot the data in the file. I have written code for it but it does not work. The data file is linked as well, as I cannot describe it properly.
Allpops=xlsread('pops.xlsx');
T=[1960,2020];
%I need a for loop to create exp1 fits for all of them and plot these fits
%on the same graph.
for k=1:length(Allpops(1,:));
ft=fittype('exp1');
[Fit,gof]=fit(T,k,ft);
plot(T,Fit);
hold on;
drawnow;
end

Réponse acceptée

KSSV
KSSV le 28 Juin 2021
Allpops=xlsread('pops.xlsx');
T = (1961:2020)' ;
%I need a for loop to create exp1 fits for all of them and plot these fits
%on the same graph.
for k=1:length(Allpops(1,:))
y = Allpops(k,:)' ;
Fit=fit(T,y,'poly2');
plot(Fit,T,y);
drawnow;
end
  1 commentaire
Petch Anuwutthinawin
Petch Anuwutthinawin le 28 Juin 2021
The code works but it makes a new graph every time the loop runs, it does not save all the data into just one graph. How do I make it save all the data onto just one graph?
Also how do I make it stop plotting the raw data, I dont see a line of code that should plot raw data.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Graphics Performance dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by