Matlab is plotting the graph incorrectly
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
I have a list of data and some initial parameter estimates (p), and the model i want to use RNp. However, after plotting both (t,RN) and then (t,RNp) on excel using the intial paramter estimates, the curve for (t,RNp) is competely off in Matlab and i cannot understand why.For some reason the values for t are fine but the values for RNp remain constant. I'm fairly new to Matlab so maybe i'm missing something in the coding. And would fmincon or lsqcurvefit be better for the parameter fitting? Thank you for any help :)

3 comentarios
Walter Roberson
el 13 de Mzo. de 2020
Unfortunately when I copy the image of your code into MATLAB, it just gives me an image of an error message telling me that it can only execute real code, not pictures of code.
Respuestas (1)
Walter Roberson
el 13 de Mzo. de 2020
CPA is a vector. It appears on the right hand side of the / expression, so the right hand side is a vector. When you use the / operation with a vector right hand side, you are not invoking division: you are invoking the least-squared fitting operator whose formal name is "matrix right divide".
To get division instead of model fitting, you need to use the ./ operator instead of the / operator.
Note that with your numerator and denominator both being vectors, using the ./ operator would give you a vector result for RNp .
If for some reason you intend matrix-right-divide instead of element-by-element division then at the very least you should add a comment about that. Better would be to re-arrange the terms and use the \ operator: A/B for real matrix A and B is B.'\A.' which MATLAB programmers would immediately recognize as being a fitting instead of a division operator.
Ver también
Categorías
Más información sobre Get Started with Curve Fitting Toolbox en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!