Matlab问题求大神帮忙Attempted to access Xs(-17.23); index must be a positive integer or logical.clear;clc;format long% 定义参数V1=2330*1000; V2=3240*1000;X0=2.73;Z0=17.23;Xs=50;Zs=50;Zb=0;% Ferrari's MethodB=(V2*V2)/(V1*V1);P4=B-1;P3=2

来源:学生作业帮助网 编辑:作业帮 时间:2024/05/12 00:35:37
Matlab问题求大神帮忙Attempted to access Xs(-17.23); index must be a positive integer or logical.clear;clc;format long% 定义参数V1=2330*1000; V2=3240*1000;X0=2.73;Z0=17.23;Xs=50;Zs=50;Zb=0;% Ferrari's MethodB=(V2*V2)/(V1*V1);P4=B-1;P3=2

Matlab问题求大神帮忙Attempted to access Xs(-17.23); index must be a positive integer or logical.clear;clc;format long% 定义参数V1=2330*1000; V2=3240*1000;X0=2.73;Z0=17.23;Xs=50;Zs=50;Zb=0;% Ferrari's MethodB=(V2*V2)/(V1*V1);P4=B-1;P3=2
Matlab问题求大神帮忙Attempted to access Xs(-17.23); index must be a positive integer or logical.
clear;clc;
format long
% 定义参数
V1=2330*1000; 
V2=3240*1000;
X0=2.73;
Z0=17.23;
Xs=50;
Zs=50;
Zb=0;


% Ferrari's Method
B=(V2*V2)/(V1*V1);
P4=B-1;
P3=2*X0-2*B*X0+2*Xs-2*B*Xs;
P2=B*X0*X0-X0*X0-4*X0*Xs+4*B*X0*Xs-Xs*Xs+B*Xs*Xs-(-Z0+Zb)*(-Z0+Zb)+B*(-Zb+Zs)*(-Zb+Zs);
P1=2*X0*X0*Xs-2*B*X0*X0*Xs+2*X0*Xs*Xs-2*B*X0*Xs*Xs+2*Xs(-Z0+Zb)*(-Z0+Zb)-2*B*X0(-Zb+Zs)*(-Zb+Zs);
P0=-X0*X0*Xs*Xs+B*X0*X0*Xs*Xs-Xs*Xs*(-Z0+Zb)*(-Z0+Zb)+B*X0*X0*(-Zb+Zs)*(-Zb+Zs);
P=[P4 P3 P2 P1 P0];
Xb=roots(P);

Matlab问题求大神帮忙Attempted to access Xs(-17.23); index must be a positive integer or logical.clear;clc;format long% 定义参数V1=2330*1000; V2=3240*1000;X0=2.73;Z0=17.23;Xs=50;Zs=50;Zb=0;% Ferrari's MethodB=(V2*V2)/(V1*V1);P4=B-1;P3=2
错误提醒的意思是Xs(-17.23)这个下标不是正整数,matlab里数组的索引只能是正整数哦.