Change data in Matlab table

조회 수: 2 (최근 30일)
ionut
ionut 2013년 1월 19일
The next code is generating the table:
%Program start:
ek1=0;
ek2=0;
ek3=0;
uk1=0;
uk2=0;
uk3=0;
yk1=0;
yk2=0;
wk=1;
for k=0:36
yk=0.19897725*uk1+0.15764221*uk2+1.42526141*yk1-0.496585302*yk2; vy(k+1)=yk;
ek=wk-yk;
ve(k+1)=ek
uk=3.633713*ek-.1511479*ek1+4.6158145*ek2-0.979647*ek3+0.8868*uk1+0.651103*uk2-0.537903*uk3;
vu(k+1)=uk;
uk3=uk2;uk2=uk1;uk1=uk;
yk2=yk1;yk1=yk;
ek3=ek2;ek2=ek1;ek1=ek;
end
plot(vy,'-g')
hold on
plot(ve,'-r')
hold on
plot(vu,'-b')
grid
%Generating the table in Matlab:
f = figure('Position',[200 150 300 150]);
k=0:1:36;
k';
vy';
ve';
vu';
dat=[k' vy' ve' vu'];
cname={'K','YK','EK','UK'};
rname={'0','1','2','3','4','5','6','7','8','9','10','11','12','13','14','15','16','17','18','19','20','21','22','23','24','25','26','27','28','29','30','31','32','33','34','35','36'};
t=uitable('Parent',f,'Data',dat,'ColumnName',cname,'RowName',rname,'Position',[10 1 700 686]);
%End of program
Is there any method to appear 0 on EK column of the table, instead of ...e-04(05 06 and 07)?
Many thanks!
  댓글 수: 2
Image Analyst
Image Analyst 2013년 1월 19일
편집: Image Analyst 2013년 1월 19일
Edit - I fixed the mangled, un-runnable formatting. Simply copying and pasting your code did not work.
ionut
ionut 2013년 1월 19일
I don't understand what do you mean.

댓글을 달려면 로그인하십시오.

채택된 답변

Image Analyst
Image Analyst 2013년 1월 19일
I don't see anything smaller than 1e-04 in your table, but if you did, this is how you can set those values to zero:
% Set everything smaller that +/- 1e-03 to zero.
ve(abs(ve) < 1e-3) = 0;
Put that code after the look where you calculate ve.
  댓글 수: 1
ionut
ionut 2013년 1월 19일
It works. Thank you!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Tables에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by