How to plot and fit a simple cell
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentario
Bob Thompson
el 3 de En. de 2019
Editada: Bob Thompson
el 3 de En. de 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.
Respuestas (0)
Ver también
Categorías
Más información sobre Interpolation en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!