Effacer les filtres
Effacer les filtres

Error using sym/subsindex

1 vue (au cours des 30 derniers jours)
Susmit Kumar Sahu
Susmit Kumar Sahu le 9 Juil 2020
I need to make this code work.
Trying for 2 days, Please someone help me to debug this error.
Error displayed
clc
clear
Start = input("Enter the Start value: ");
End = input("Enter the End value: ");
grid_size = input("Enter the grid size: ");
np = input("Enter the number of input points: ");
x = zeros(1,np,'uint32');
y = zeros(1,np,'uint32');
i = 1;
while i <= np
x(i) = input("Coordinates of X value: ");
y(i) = input("Coordinates of y value: ");
i = i + 1;
end
j = 1;
px = zeros(1,np);
py = zeros(1,np);
syms j
for t =0:1:0.01
blending_function = (factorial(np)/factorial(j)*factorial(np-j)).*(t.^j).*(1-t).^(np-j))
px = symsum((blending_function.*x(j+1),j,0,np-1);
py = symsum(((factorial(np)/factorial(j)*factorial(np-j)).*(t.^j).*(1-t).^(np-j)).*y(j+1),j,0,np-1);
end
%px=(1-t).^3*x(1)+3*t.*(1-t).^2*x(2)+3*t.^2.*(1-t)*x(3)+t.^3*x(4);
%py=(1-t).^3*y(1)+3*t.*(1-t).^2*y(2)+3*t.^2.*(1-t)*y(3)+t.^3*y(4);
title("Bezier Curve for cloud points")
grid on
grid minor
plot(x,y);
hold
plot(px,py,'r');
xlabel('postition in x');
ylabel('position in y');
legend('Actual curve','Bezier Curve');
%axis([0 4.2 0 3.2]);
  3 commentaires
madhan ravi
madhan ravi le 9 Juil 2020
It’s so confusing, mind posting the latex equation?
Susmit Kumar Sahu
Susmit Kumar Sahu le 9 Juil 2020
Please help me rectifying now.

Connectez-vous pour commenter.

Réponses (1)

Devineni Aslesha
Devineni Aslesha le 22 Juil 2020
Hi Susmit
In the given code, the error is due to the presence of x(j+1) and y(j+1) that belongs to Class uint32. However, the Expression defining terms of series in symsum should be symbolic (Class: sym). Make sure what is the purpose of using x and y in your code and convert it to symbolic expression. If you remove x(j+1) and y(j+1), the code runs without any error.

Catégories

En savoir plus sur Symbolic Math Toolbox dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by