# I don't know what to do anymore,modeling the equation y=a3x^3 + a2x^2 + a1x +a0

3 ビュー (過去 30 日間)
Nohemi Yazmin 2022 年 11 月 29 日
コメント済み: Nohemi Yazmin 2022 年 11 月 29 日
Hello how are you, I have a task where I have to model a cubic function with start coordinates and end coordinates, the curves must be in the middle. Please help me
Equation y=a3x^3 + a2x^2 + a1x +a0
These are the coordinates:
Initial(100,2900) final(2600,800)
Thank you

サインインしてコメントする。

### 採用された回答

Image Analyst 2022 年 11 月 29 日
Two points is not enough to fit a cubic. You'd need at least 4 points. If you have 4 x and 4 y then you can do
x = sort(10 * rand(1, 4));
y = 10 * rand(1, 4);
plot(x, y, 'b.', 'MarkerSize', 30);
grid on;
coefficients = polyfit(x, y, 3)
coefficients = 1×4
0.2599 -3.6261 12.9042 -2.2341
xFit = linspace(min(x), max(x), 1000);
yFit = polyval(coefficients, xFit);
hold on;
plot(xFit, yFit, 'r-', 'lineWidth', 2);
xlabel('x');
ylabel('y');
legend('training data', 'Fitted Curve') If you have any more questions, then attach your data and code to read it in with the paperclip icon after you read this:
##### 1 件のコメント表示非表示 なし
Nohemi Yazmin 2022 年 11 月 29 日
Thank you so much, I will ask my teacher what happen with the others points, you are so kind :)

サインインしてコメントする。

### カテゴリ

Find more on Smoothing in Help Center and File Exchange

R2022b

### Community Treasure Hunt

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

Start Hunting!