matlab调用龙格库塔法出错In an assignment A(I) = B,the number of elements in B and I must be the使用RK4求解常微分出错,常微方程如下,h+d=23为常量,欧米茄是已知的数组,共27个元素,程序中用omg定义.θ是定义的

来源:学生作业帮助网 编辑:作业帮 时间:2024/03/29 18:15:41
matlab调用龙格库塔法出错In an assignment A(I) = B,the number of elements in B and I must be the使用RK4求解常微分出错,常微方程如下,h+d=23为常量,欧米茄是已知的数组,共27个元素,程序中用omg定义.θ是定义的

matlab调用龙格库塔法出错In an assignment A(I) = B,the number of elements in B and I must be the使用RK4求解常微分出错,常微方程如下,h+d=23为常量,欧米茄是已知的数组,共27个元素,程序中用omg定义.θ是定义的
matlab调用龙格库塔法出错In an assignment A(I) = B,the number of elements in B and I must be the
使用RK4求解常微分出错,常微方程如下,h+d=23为常量,欧米茄是已知的数组,共27个元素,程序中用omg定义.θ是定义的等差数组,用seita定义,是自变量,应该也是27个元素,x是应变量.θ初始为0,x为-15 .


function inner = sax(varargin)
clc,clear
h1=8;d=15;l=2000;n=1.4;
h=pi/160;max_omg=30*pi/180;xn=pi/6;y0=0;
seita=[0:pi/160:pi/6];
lk=length(seita);
yt=[0,45.3421,90.6667,135.9563,181.1935,226.3609,271.441,316.4164,361.2699,405.9841,450.5418,494.9258,539.119,583.1043,626.8649,670.3837,713.6442,756.6295,799.3231,841.7086,883.7695,925.4898,966.8532,1007.844,1048.4461,1088.6441,1128.4224]
omg=[0,0.0152,0.0303,0.0454,0.0605,0.0754,0.0902,0.1048,0.1193,0.1336,0.1477,0.1615,0.1752,0.1885,0.2016,0.2144,0.227,0.2392,0.2511,0.262,0.274,0.285,0.2957,0.3061,0.3161,0.3258,0.3353]
global omg;global seita;


[y,x]=lgkt(d,lk,h) ;%调用rk4


function z=f(seita,x) %rk4子函数
global omg;global seita;
h1=8;d=15;n=1.4;
fenzi=h1+d+x;
fenmu=(-(n*cos(omg)-cos(seita))/(n*sin(omg)-sin(seita))-tan(seita)).*((cos(seita)).^2);
z=fenzi./fenmu;%常微分方程
function [seita,x]=lgkt(d,lk,h)
global seita;
x(1)=-d;
y1=seita;
y1(1)=0;
for i=1:(lk-1)
    K1=f(y1(i),x(i));     %x为x左边 y为出射角度θ
    K2=f(y1(i)+h/2,x(i)+h/2*K1);
    K3=f(y1(i)+h/2,x(i)+h/2*K2);
    K4=f(y1(i)+h,x(i)+h*K3);
    x(i+1)=x(i)+h/6*(K1+2*K2+2*K3+K4);
end
y=y1;
plot(x,y)


matlab提示
  In an assignment  A(I) = B, the number of elements in B and
 I must be the same.
Error in ==> axs>lgkt at 31
    x(i+1)=x(i)+h/6*(K1+2*K2+2*K3+K4);
Error in ==> axs at 13
[y,x]=lgkt(d,lk,h) ;

matlab调用龙格库塔法出错In an assignment A(I) = B,the number of elements in B and I must be the使用RK4求解常微分出错,常微方程如下,h+d=23为常量,欧米茄是已知的数组,共27个元素,程序中用omg定义.θ是定义的
我只能说你的程序很乱,一堆没有用到的变量,不知道你在想什么.最关键的是常微分方程的omg不应该是定值吗,也即是说对每一个给定的omg值都有一个常微分方程的解与之对应.我帮你改了一下.仅供参考.
function sax
clc;clear;
h=pi/160;
seita=0:h:pi/6;
x0=-15;
x=lgkt(seita,x0,h);%调用rk4
plot(seita,x)
end
function x=lgkt(seita,x0,h)
y1=seita;
x=zeros(size(y1));
x(1)=x0;
for i=1:length(seita)-1
K1=f(y1(i),x(i));%x为x左边y为出射角度θ
K2=f(y1(i)+h/2,x(i)+h/2*K1);
K3=f(y1(i)+h/2,x(i)+h/2*K2);
K4=f(y1(i)+h,x(i)+h*K3);
x(i+1)=x(i)+h/6*(K1+2*K2+2*K3+K4);
end
end
function z=f(seita,x)%rk4子函数
h1=8;%这里修改
d=15;
n=1.4;
omg=0.2;
fenzi=h1+d+x;
fenmu=(-(n*cos(omg)-cos(seita))/(n*sin(omg)-sin(seita))-tan(seita)).*((cos(seita)).^2);
z=fenzi./fenmu;%常微分方程
end

matlab logical出错logical(x(1).a)(:,1)我是要调用x(1).a这个矩阵的逻辑形式的第1列,结果出错:Error:()-indexing must appear last in an index expression. matlab调用龙格库塔法出错In an assignment A(I) = B,the number of elements in B and I must be the使用RK4求解常微分出错,常微方程如下,h+d=23为常量,欧米茄是已知的数组,共27个元素,程序中用omg定义.θ是定义的 MATLAB函数调用时为什么出现 In an assignment A(I) = B,the number of elements 用matlab调用freqz函数出错,点帮助有两个freqz函数,一... 用matlab解常微分方程组,为什么会出错?调用的是dsolve的函数. Matlab 出错 matlab出错, matlab 求和的出错 用matlab解常微分方程,调用dsolve是老出错 y=dsolve('Dy=x*sin(x)/cos(y)','x')错误如下:Error using ==> putenvmaplevalue truncatedError in ==> mapleinit at 41putenvmaple('maple',base);Error in ==> maple at 113[result,status] = maplemex( matlab 怎么调用拉格朗日函数 关于matlab,simulink仿真问题,一直有Error in fun (line 2) k=x(1);,调用lsqcurvefit就出错open_system('sim1');sim('sim1');load dataty.mat;x0=[1,2,2];t=out(1,:);y=out(2,:);x=lsqcurvefit('fun',x0,t,y);plot(t,fun(x,t),'-',t,y,'-*');function y=f matlab编程,如何将3个3*1数组放入矩阵,构成3*3矩阵,并且能够矩阵中各个数组,分别进行调用运算.一维数组已经实现,并且可以调用特定数组进行运算,如图然后尝试输入3*1数时候,出现错误:In an a matlab 如何创建并调用m文件 matlab中~.m文件中的函数:function [Yhard,Ysoft] = treeTest(model,X,opts);在另外一个文件中调用.m文件中的这个函数:,ysoft]=treeTest(model1,X,opts);,一直出错:Expression or statement is incorrect--possibly unbalanced (, matlab打开出错,请问怎么解决? matlab怎么调用函数:我编了一段程序在M文件里,如何调用呢? matlab 中如何调用M文件中函数? There is ___ u,___ s and ___ e in use.(a/an)出错题了! 应该是这道题 There is ( ) “P,( )“E”and ( )N in pen.(a/an)