Change data in Matlab table
4 views (last 30 days)
Show older comments
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 Comments
Image Analyst
on 19 Jan 2013
Edited: Image Analyst
on 19 Jan 2013
Edit - I fixed the mangled, un-runnable formatting. Simply copying and pasting your code did not work.
Accepted Answer
Image Analyst
on 19 Jan 2013
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.
More Answers (0)
See Also
Categories
Find more on Tables in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!