フィルターのクリア

trouble with basic plotting,

2 ビュー (過去 30 日間)
Dan
Dan 2011 年 7 月 18 日
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

採用された回答

Sean de Wolski
Sean de Wolski 2011 年 7 月 18 日
??? 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 件)

カテゴリ

Help Center および File ExchangeInterpolation についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by