How to display a table in the command window?

9 ビュー (過去 30 日間)
Jeroen
Jeroen 2013 年 3 月 30 日
In my previous question ( http://www.mathworks.nl/matlabcentral/answers/69224-how-to-write-a-function-that-generates-a-hyperlink-that-runs-a-function ) I learned to display a list of hyperlinks in the command window, but now I would like to display them in a table with two columns and 4 rows (one for every integration method). I already found soms things on the internet to make a table:
tabel = ModelAdvisor.Table(2,4);
setHeading(tabel, 'All the methods to calculate integrals');
setHeadingAlign(tabel, 'center');
setRowHeading(tabel, 1, 'With graph');
setRowHeadingAlign(tabel, 1, 'center');
setRowHeading(tabel, 2, 'Without graph');
setRowHeadingAlign(tabel, 2, 'center');
The problem is that I don't understand how I can actually edit information, namely hyperlinks (see previous question), in the tabel.
Can someone help me?
-----
Edit: I'll be a bit more specific. I implemented 3 methods to approximate the integral of a function: riemann_Uf, riemann_Lf and trapezoid. Each method has 2 variants: a function that only calculates the integral (name of the function ends with _exgr) and another function that also draws the graph of the function (name ends with _ingr). For the drawing of the graph, I wrote a function integral_graph. Every function needs 4 arguments: f, a, b and n (see previous question). When one calls the function integral with these arguments, I'd like a table to be displayed in the command window looking like this:
*With graph* *Without graph*
Riemann Uf Riemann Uf
Riemann Lf Riemann Lf
Trapezoid's Rule Trapezoid's Rule
Where clicking on for exemple Riemann Uf in the first column runs the function riemann_Uf_ingr(f,a,b,n) and clicking on Trapezoid's Rule in the second column calls the function trapezoid_exgr(f,a,b,n).

採用された回答

Walter Roberson
Walter Roberson 2013 年 3 月 31 日
Example:
syms x
f{1} = x^2 + sin(x);
cw1 = 10; %width of column #1
cw2 = 12; %width of column #2
lb = 3; ub = pi; n = 50;
ftable = { 'riemann', 'Riemann'; 'trapezoid', 'Trapezoid' };
fvals = [17.3; -4.2]; %numeric values for table
graphit = true;
fprintf('With graph\n');
for K = 1 : size(ftable, 1)
fstr = sprintf( 'sym(''%s'')', char(f{1}));
fcall = sprintf('%s(%s,%f,%f,%d,%d)', ftable{K,1}, fstr, lb, ub, n, graphit);
fprintf('<matlab:%s %*s> %*g\n', fcall, cw1, ftable{K,2}, cw2, fvals(K));
end
  8 件のコメント
Jeroen
Jeroen 2013 年 4 月 1 日
Mission table accomplished! Thanks for all the help, Walter!
Jorge Ignacio Cisneros Saldana
Jorge Ignacio Cisneros Saldana 2022 年 7 月 13 日
Do you know how to export this table as pdf or png?

サインインしてコメントする。

その他の回答 (0 件)

製品

Community Treasure Hunt

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

Start Hunting!

Translated by