请问怎样去掉matlab运算过程会显示数组的值?
用matlab写GUI程序的时候,里面有一个1*10000的数组,但是每次对它进行运算的时候,程序都会在commandwindow里面把数组的10000个值显示出来,程序...
用matlab写GUI程序的时候,里面有一个1*10000的数组,但是每次对它进行运算的时候,程序都会在command window里面把数组的10000个值显示出来,程序运行异常的慢。。求各位大神解决一下:下面是那一段的代码:
Mz = zeros(1,10000);
for k=1: 10000
for j=1:FSum
if t(k)<FPos(j)
Mz(k) = Mz(k)+F(j)*(len-FPos(j))*t(k)/(E*I*len);
else
Mz(k) = Mz(k)-F(j)*(len-FPos(j))*(len/(len-FPos(j))*(FPos(j)-t(k))+t(k))/(E*I*len);
end;
end;
for j=1:MSum
if t(k)<MPos(j)
Mz(k) = Mz(k)-M(j)*t(k)/(E*I*len);
else
Mz(k) = Mz(k)+M(j)*(len-t(k))/(E*I*len);
end
end;
for j=1:qSum
if t(k)<StartPos(j)
Mz(k) = Mz(k)+Fa*t(k);
elseif t(k)<EndPos(j)
Mz(k) = Mz(k)+Fa*t(k)-(q(j)*(t(k)-StartPos(j))^2)/2;
else Mz(k) = Mz(k)+Fa*t(k)-(q(j)*(t(k)-StartPos(j))^2)/2+(q(j)*(t(k)-EndPos(j))^2)/2;
end
end;
end;
maxMz = 0;
for k=1:10000
if (abs(Mz(k))>abs(maxMz))
maxMz = Mz(k);
end;
end;
%画弯矩图
axes(handles.axes2);
plot(t,Mz,'b',t,0,'k');
V = [0,len,-abs(1.2*maxMz),abs(1.2*maxMz)];
axis(V);
set(handles.text21,'String',num2str(maxMz));
----------------------------------------------------------------
另外还有一段类似的代码,却没有这样的问题,代码如下:
%计算剪力
FSum = str2double(get(handles.text30,'String'));
MSum = str2double(get(handles.text32,'String'));
qSum = str2double(get(handles.text34,'String'));
Fsy = zeros(1,10000);
for k=1: 10000
for j=1:FSum
if t(k)<FPos(j)
Fsy(k) = Fsy(k)+F(j)/(E*I*len);
else
Fsy(k) = Fsy(k)+F(j)*(len-FPos(j))*(1-len/(len-FPos(j)))/(E*I*len);
end;
end;
for j=1:MSum
Fsy(k) = Fsy(k)-M(j)/(E*I*len);
end;
for j=1:qSum
if t(k)<StartPos(j)
Fsy(k) = Fsy(k)-q(j)*(qSpan(j))-q(j)*(EndPos(j)^2-StartPos(j)^2)/(2*len);
elseif (t(k)>=StartPos(j) && t(k)<EndPos(j))
Fsy(k) = Fsy(k)-q(j)*qSpan(j)-q(j)*(StartPos(j)^2-EndPos(j)^2)/(2*len);
else
Fsy(k) = Fsy(k)+q(j)*(StartPos(j)^2-EndPos(j)^2)/(2*len);
end;
end;
end
maxFsy =0;
for k =1:10000
if (abs(Fsy(k))>abs(maxFsy))
maxFsy = Fsy(k)
end;
end;
%画剪力图
axes(handles.axes1);
plot(t,Fsy,'b',t,0,'k');
V = [0,len,-abs(1.2*maxFsy),abs(1.2*maxFsy)];
axis(V);
set(handles.text17,'String',num2str(maxFsy));
--------------------------------------------------------------------
感觉这两段代码都差不多啊。。。为什么前面那段代码就会使command window输出数组的值,后面那段代码就不会输出数组的值呢?谢谢。 展开
Mz = zeros(1,10000);
for k=1: 10000
for j=1:FSum
if t(k)<FPos(j)
Mz(k) = Mz(k)+F(j)*(len-FPos(j))*t(k)/(E*I*len);
else
Mz(k) = Mz(k)-F(j)*(len-FPos(j))*(len/(len-FPos(j))*(FPos(j)-t(k))+t(k))/(E*I*len);
end;
end;
for j=1:MSum
if t(k)<MPos(j)
Mz(k) = Mz(k)-M(j)*t(k)/(E*I*len);
else
Mz(k) = Mz(k)+M(j)*(len-t(k))/(E*I*len);
end
end;
for j=1:qSum
if t(k)<StartPos(j)
Mz(k) = Mz(k)+Fa*t(k);
elseif t(k)<EndPos(j)
Mz(k) = Mz(k)+Fa*t(k)-(q(j)*(t(k)-StartPos(j))^2)/2;
else Mz(k) = Mz(k)+Fa*t(k)-(q(j)*(t(k)-StartPos(j))^2)/2+(q(j)*(t(k)-EndPos(j))^2)/2;
end
end;
end;
maxMz = 0;
for k=1:10000
if (abs(Mz(k))>abs(maxMz))
maxMz = Mz(k);
end;
end;
%画弯矩图
axes(handles.axes2);
plot(t,Mz,'b',t,0,'k');
V = [0,len,-abs(1.2*maxMz),abs(1.2*maxMz)];
axis(V);
set(handles.text21,'String',num2str(maxMz));
----------------------------------------------------------------
另外还有一段类似的代码,却没有这样的问题,代码如下:
%计算剪力
FSum = str2double(get(handles.text30,'String'));
MSum = str2double(get(handles.text32,'String'));
qSum = str2double(get(handles.text34,'String'));
Fsy = zeros(1,10000);
for k=1: 10000
for j=1:FSum
if t(k)<FPos(j)
Fsy(k) = Fsy(k)+F(j)/(E*I*len);
else
Fsy(k) = Fsy(k)+F(j)*(len-FPos(j))*(1-len/(len-FPos(j)))/(E*I*len);
end;
end;
for j=1:MSum
Fsy(k) = Fsy(k)-M(j)/(E*I*len);
end;
for j=1:qSum
if t(k)<StartPos(j)
Fsy(k) = Fsy(k)-q(j)*(qSpan(j))-q(j)*(EndPos(j)^2-StartPos(j)^2)/(2*len);
elseif (t(k)>=StartPos(j) && t(k)<EndPos(j))
Fsy(k) = Fsy(k)-q(j)*qSpan(j)-q(j)*(StartPos(j)^2-EndPos(j)^2)/(2*len);
else
Fsy(k) = Fsy(k)+q(j)*(StartPos(j)^2-EndPos(j)^2)/(2*len);
end;
end;
end
maxFsy =0;
for k =1:10000
if (abs(Fsy(k))>abs(maxFsy))
maxFsy = Fsy(k)
end;
end;
%画剪力图
axes(handles.axes1);
plot(t,Fsy,'b',t,0,'k');
V = [0,len,-abs(1.2*maxFsy),abs(1.2*maxFsy)];
axis(V);
set(handles.text17,'String',num2str(maxFsy));
--------------------------------------------------------------------
感觉这两段代码都差不多啊。。。为什么前面那段代码就会使command window输出数组的值,后面那段代码就不会输出数组的值呢?谢谢。 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询