Output of a Function in a graph and table

조회 수: 8 (최근 30일)
Hassan Ghanem
Hassan Ghanem 2019년 5월 27일
답변: MSP 2019년 5월 30일
I have a set of functions that I need to express as a graph as well as show the data in a table in separate figures. How do I go about this? The disp function did not work out nor is using the basic 'table' code since it requires data to already be there. Thank you for your help!
  댓글 수: 7
Hassan Ghanem
Hassan Ghanem 2019년 5월 30일
All I am really trying to accomplish is that when I plot a set of functions, I also obtain a table with the independent and dependent variables. ex:
y1 = x^2
y2 = x^3
y3 = x^4
plot( x, y1)
hold on
plot( x, y2)
hold on
plot(x,y3)
hold off
xlabel('area available for bacteria growth');
ylabel('concentration of bacteria');
legend('y1=bacteria1', 'y2=bacteria2', y3=bacteria3');
Then when this is run, a graph pops up. I am seeking a code (table, fprintf, etc) that will also have a figure of the correstponding values of the inputs and outputs for a range of x-values.
Thank you all for your help!
dpb
dpb 2019년 5월 30일
Look at uitable or the text function, perhaps...

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

채택된 답변

MSP
MSP 2019년 5월 30일
Something like that?
Table.PNG
I ended up doing it pretty quick just to get the idea to solution since I'm not 100% of what you're wanting. The idea here is to create a figure, use the subplot to plot the graph and use uitable to plot the table..
% Example of a Dataset (Matrix)
ExAr = randi(100,20,8);
% Get size of the screen to make determinate the size of the window
Size = get(0,'ScreenSize');
Mx = Size(3)/2;
My = Size(3)/2;
Fig_left = Mx/2;
Fig_bott = My/4;
Fig_width = Mx;
Fig_height = My/2;
% Create Figure with Postion, Title and resize off
f = figure('Name','Data Plot', 'NumberTitle','off', ...
'Position',[Fig_left Fig_bott Fig_width Fig_height], 'Resize','off');
% Create Table on the left side of the figure
uit = uitable(f,'Data',ExAr,'Position',[1 1 Fig_height (Fig_width/2)]);
% Create Plot on the right side of the figure
s1 = subplot(1,2,2);
plot(ExAr(1,:),ExAr(3,:))
If you get the idea behinde it you can change and adapt it for your problem..
Hope it helps!

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Specifying Target for Graphics Output에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by