How to display a table in the command window?
10 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Jeroen
el 30 de Mzo. de 2013
Comentada: Jorge Ignacio Cisneros Saldana
el 13 de Jul. de 2022
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).
0 comentarios
Respuesta aceptada
Walter Roberson
el 31 de Mzo. de 2013
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 comentarios
Jorge Ignacio Cisneros Saldana
el 13 de Jul. de 2022
Do you know how to export this table as pdf or png?
Más respuestas (0)
Ver también
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!