How to plot and fit a simple cell
3 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
I have a 1x220 cell (a) with each element being a 1x4 cell. I would like to plot the four elements of the 1x4 cells on the y axis, with the x axis simply being 1 through 4. I would then like to find the line of best fit (m of y=mx+b) for each of the 220 plots. Within the 1x4 cells is numerical data, one number as each element.
I currently have something along the lines of:
counter = 1:4;
for i = 1:220
plot(counter, a(i));
fit(counter, a(i), 'poly1');
end
But the plot does not seem to work. I receive an error that says "Invalid data argument".
If finding the slope (m) is doable without having to plot I would prefer to do that though I do not know how.
1 Commento
Bob Thompson
il 3 Gen 2019
Modificato: Bob Thompson
il 3 Gen 2019
You might find it easier of you bring the data out into a 4x220 or 220x4 array first (look up cell2mat). Then it can just be a double and should smooth things quite a bit. It would also be possible to add another column or row with the numbers 1:4 in them.
Risposte (0)
Vedere anche
Categorie
Scopri di più su Interpolation in Help Center e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!