Warning: Error creating or updating Surface Error in value of property XData Array is wrong shape or size

When I run this code I get the Warning: Error creating or updating Surface Error in value of property XData Array is wrong shape or size, pls help
P=[7.35991,-1.0882;%C Lineal C-D 1
7.16447,-0.98211;%D Lineal C-D/Noveno grado D,E,F,I,J,K,L,M,N,O 2
6.91296,-0.89726;%E Noveno grado D,E,F,I,J,K,L,M,N,O 3
6.62118,-0.845;%F Noveno grado D,E,F,I,J,K,L,M,N,O 4
6.28584,-0.81016;%I Noveno grado D,E,F,I,J,K,L,M,N,O 5
5.88954,-0.79709;%J Noveno grado D,E,F,I,J,K,L,M,N,O 6
5.54114,-0.79274;%K Noveno grado D,E,F,I,J,K,L,M,N,O 7
5.2,-0.8;%L Noveno grado D,E,F,I,J,K,L,M,N,O 8
4.90531,-0.82883;%M Noveno grado D,E,F,I,J,K,L,M,N,O 9
4.6054,-0.8916;%N Noveno grado D,E,F,I,J,K,L,M,N,O 10
4.41709,-0.94739;%O Noveno grado D,E,F,I,J,K,L,M,N,O/Tercer grado O,Q,R 11
4.08276,-1.08392;%Q Tercer grado O,Q,R 12
3.8662,-1.25019;%R Tercer grado O,Q,R/ Lineal R-S 13
3.69636,-1.71736;%S Lineal R-S 14
1.05625,-1.72669;%W Lineal S-W/ Tercer grado W,Z,A1 15
1.04708,-1.57082;%Z Tercer grado W,Z,A1 16
1.02791,-1.39335;%A1 Tercer grado W,Z,A1/ Tercer grado A1,B1,C1 17
0.99755,-1.31476;%B1 Tercer grado A1,B1,C1 18
0.93314,-1.24084;%C1 Tercer grado A1,B1,C1/ Tercer grado C1,D1,E1 19
0.86222,-1.20885;%D1 Tercer grado C1,D1,E1 20
0.71549,-1.33227;%E1 Tercer grado C1,D1,E1/ Cuarto grado E1,F1,H1,J1 21
0.69622,-1.46909;%F1 Cuarto grado E1,F1,H1,J1 22
0.68342,-1.60478;%H1 Cuarto grado E1,F1,H1,J1 23
0.67727,-1.73281;]%J1 Cuarto grado E1,F1,H1,J1 24
P = 24×2
7.3599 -1.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(11,1)^5 P(11,1)^4 P(11,1)^3 P(11,1)^2 P(11,1) 1];
F2B = [P(2,2);
P(3,2);
P(4,2);
P(5,2);
P(6,2);
P(7,2);
P(8,2);
P(9,2);
P(10,2);
P(11,2)];
% Inversa
coef2 = inv(F2A) * F2B;
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 3.573032e-17.
% Mostrar ecuación
fprintf("Polinomio 2 noveno grado y=%f x^9 + %f x^8 + %f x^7 + %f x^6 + %f x^5 + %f x^4 + %f x^3 + %f x^2 + %fx + %f \n",coef2(1),coef2(2),coef2(3),coef2(4),coef2(5),coef2(6),coef2(7),coef2(8),coef2(9))
Polinomio 2 noveno grado y=-0.010884 x^9 + 0.554546 x^8 + -12.517521 x^7 + 164.303711 x^6 + -1382.153954 x^5 + 7728.176185 x^4 + -28724.141729 x^3 + 68439.569989 x^2 + -94860.851589x +
%Función 3
F3A = [P(11,1)^2 P(11,1) 1;
P(12,1)^2 P(12,1) 1;
P(13,1)^2 P(13,1) 1]
F3A = 3×3
19.5107 4.4171 1.0000 16.6689 4.0828 1.0000 14.9475 3.8662 1.0000
F3B = [P(11,2);
P(12,2);
P(13,2)];
% Resolver sistema de ecuaciones utilizando la inversa
coef3 = inv(F3A)*F3B;
% Mostrar ecuación
fprintf("Polinomio 3 tercer grado y=%f x^2 + %fx + %f \n",coef3(1),coef3(2),coef3(3))
Polinomio 3 tercer grado y=-0.652415 x^2 + 5.953800x + -14.516795
%Función 4
F4A = [P(13,1) 1;
P(14,1) 1];
F4B = [P(13,2);
P(14,2)];
% Resolver sistema de ecuaciones utilizando la inversa
coef4 = inv(F4A)*F4B;
% Mostrar ecuación
fprintf("Polinomio 4 primer grado y=%fx + %f \n",coef4(1),coef4(2))
Polinomio 4 primer grado y=2.750648x + -11.884744
%FUNCION 5
F5A = [P(14,1) 1;
P(15,1) 1];
F5B = [P(14,2);
P(15,2)];
% Resolver sistema de ecuaciones utilizando la inversa
coef5 = inv(F5A)*F5B;
% Mostrar ecuación
fprintf("Polinomio 5 primer grado y=%fx + %f \n",coef5(1),coef5(2))
Polinomio 5 primer grado y=0.003534x + -1.730423
%FUNCION 6
F6A = [P(15,1)^2 P(15,1) 1;
P(16,1)^2 P(16,1) 1;
P(17,1)^2 P(17,1) 1];
F6B = [P(15,2);
P(16,2);
P(17,2)];
% Resolver sistema de ecuaciones utilizando la inversa
coef6 = inv(F6A)*F6B;
% Mostrar ecuación
fprintf("Polinomio 6 segundo grado y=%f x^2 + %fx + %f \n",coef6(1),coef6(2),coef6(3))
Polinomio 6 segundo grado y=-273.116608 x^2 + 557.456535x + -285.833771
%FUNCION 7
F7A = [P(17,1)^2 P(17,1) 1;
P(18,1)^2 P(18,1) 1;
P(19,1)^2 P(19,1) 1];
F7B = [P(17,2);
P(18,2);
P(19,2)];
% Resolver sistema de ecuaciones utilizando la inversa
coef7 = inv(F7A)*F7B;
% Mostrar ecuación
fprintf("Polinomio 7 segundo grado y=%f x^2 + %fx + %f \n",coef7(1),coef7(2),coef7(3))
Polinomio 7 segundo grado y=-15.204765 x^2 + 28.208039x + -14.323337
%FUNCION 8
F8A = [P(19,1)^2 P(19,1) 1;
P(20,1)^2 P(20,1) 1;
P(21,1)^2 P(21,1) 1];
F8B = [P(19,2);
P(20,2);
P(21,2)];
% Resolver sistema de ecuaciones utilizando la inversa
coef8 = inv(F8A)*F8B;
% Mostrar ecuación
fprintf("Polinomio 8 segundo grado y=%f x^2 + %fx + %f \n",coef8(1),coef8(2),coef8(3))
Polinomio 8 segundo grado y=-5.937094 x^2 + 10.208149x + -5.596746
%Funcion 9
F9A = [P(21,1)^3 P(21,1)^2 P(21,1) 1;
P(22,1)^3 P(22,1)^2 P(22,1) 1;
P(23,1)^3 P(23,1)^2 P(23,1) 1;
P(24,1)^3 P(24,1)^2 P(24,1) 1]
F9A = 4×4
0.3663 0.5119 0.7155 1.0000 0.3375 0.4847 0.6962 1.0000 0.3192 0.4671 0.6834 1.0000 0.3107 0.4587 0.6773 1.0000
F9B = [P(21,2);
P(22,2);
P(23,2);
P(24,2)];
% Resolver sistema de ecuaciones utilizando la inversa
coef9 = inv(F9A)*F9B;
% Mostrar ecuación
fprintf("Polinomio 9 tercer grado y=%f x^3 + %f x^2 + %fx + %f \n",coef9(1),coef9(2),coef9(3),coef9(4))
Polinomio 9 tercer grado y=11250.796421 x^3 + -23681.036876 x^2 + 16620.316136x + -3890.983181
%% Definir para cada función rango de x en que es válida
Deltax=0.01;
x1=[P(1,1):Deltax:P(2,1)];
x2=[P(2,1):Deltax:P(11,1)];
x3=[P(11,1):Deltax:P(13,1)];
x4=[P(13,1):Deltax:P(14,1)];
x5=[P(14,1):Deltax:P(15,1)];
x6=[P(15,1):Deltax:P(17,1)];
x7=[P(17,1):Deltax:P(19,1)];
x8=[P(19,1):Deltax:P(21,1)];
x9=[P(21,1):Deltax:P(24,1)];
%% Definición de funciones para graficar y su evaluación
f1=@(x)coef1(1)*x+coef1(2);
f2=@(x)coef2(1)*x .^9 + coef2(1)*x .^8 +coef2(2)*x .^7 + coef2(3)*x .^6 + coef2(4)*x .^5 + coef2(5)*x .^4 + coef2(6)*x .^3 + coef2(7)*x .^2 + coef2(8)*x + coef2(9);
f3=@(x)coef3(1)*x .^2 + coef3(2)*x + coef3(3);
f4=@(x)coef4(1)*x+coef4(2);
f5=@(x)coef5(1)*x+coef5(2);
f6=@(x)coef6(1)*x .^2 + coef6(2)*x + coef6(3);
f7=@(x)coef7(1)*x .^2 + coef7(2)*x + coef7(3);
f8=@(x)coef8(1)*x .^2 + coef8(2)*x + coef8(3);
f9=@(x)coef9(1)*x .^3 + coef9(2)*x .^2 +coef9(3)*x + coef9(4);
y1=f1(x1);
y2=f2(x2);
y3=f3(x3);
y4=f4(x4);
y5=f5(x5);
y6=f6(x6);
y7=f7(x7);
y8=f8(x8);
y9=f9(x9);
X=[x1,x2,x3,x4,x5,x6,x7,x8,x9];
Y=[y1,y2,y3,y4,y5,y6,y7,y8,y9];
% contorno y sólido de revolución
subplot(1,2,1)
cylinder(Y)
Warning: Error creating or updating Surface
Error in value of property XData
Array is wrong shape or size

 Accepted Answer

P=[7.35991,-1.0882;%C Lineal C-D 1
7.16447,-0.98211;%D Lineal C-D/Noveno grado D,E,F,I,J,K,L,M,N,O 2
6.91296,-0.89726;%E Noveno grado D,E,F,I,J,K,L,M,N,O 3
6.62118,-0.845;%F Noveno grado D,E,F,I,J,K,L,M,N,O 4
column 1 of your P is strictly decreasing.
x1=[P(1,1):Deltax:P(2,1)];
x2=[P(2,1):Deltax:P(11,1)];
x3=[P(11,1):Deltax:P(13,1)];
Each of your x* variables has P of a lower index as the first end point, and P of a higher index as the second end point, and positive incremente Deltax. But your first column of P is strictly decreasing, so your x1 variables are all empty.

1 Comment

You were right I was graphing backwards lol... thanks so much for the help man I delivered my project on time thanks!!!

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!