trouble with basic plotting,
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hello,
I have recently been using matlab and learning its workings as I go, I am fairly new to the program. I am working on generating a best fit curve and have used the basic fitting tool and am trying to plot the cubic fit function in my program. I am not sure why it will not plot.
I wrote
dt=4E-9; % Time Step L=9999; % Length t=(0:L-1)*dt; % Time array by steps of dt x= (0:L-1)*(1/dt); yfit = 4.5e-021*x^3 - 9.9e-015*x^2 + 5.5e-009*x - 3.1e-005; plot(x,yfit,'g')
the error it gives me is
??? Error using ==> mpower Inputs must be a scalar and a square matrix. To compute elementwise POWER, use POWER (.^) instead.
Error in ==> Spectrum1210702793 at 79 yfit = 4.5e-021*x^3 - 9.9e-015*x^2 + 5.5e-009*x - 3.1e-005;
Also is there a way to generate code to copy into my m file from using the basic fitting tool.
Can you help me, thanks,
Dan
0 comentarios
Respuesta aceptada
Sean de Wolski
el 18 de Jul. de 2011
??? Error using ==> mpower Inputs must be a scalar and a square matrix. To compute elementwise POWER, use POWER (.^) instead.
This issue and solution is right there in the error message. You're trying to do a matrix power (linear algebra) when you really want an element-by-element power. The solution - put a '.' before every power.
yfit = 4.5e-021*x.^3 - 9.9e-015*x.^2 + 5.5e-009*x - 3.1e-005;
0 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Linear and Nonlinear Regression 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!