Azzera filtri
Azzera filtri

Extracting Data from Script

4 visualizzazioni (ultimi 30 giorni)
Adrian Oblena
Adrian Oblena il 2 Mag 2020
I would like to know how to get the data plotted by the script I have made. It was the solution of a pdepe problem. Thank you
  4 Commenti
Olawale Ikuyajolu
Olawale Ikuyajolu il 2 Mag 2020
Do you want to get x and u?
Adrian Oblena
Adrian Oblena il 2 Mag 2020
I want to get u(x,t)
for every x and t

Accedi per commentare.

Risposta accettata

KALYAN ACHARJYA
KALYAN ACHARJYA il 2 Mag 2020
Modificato: KALYAN ACHARJYA il 2 Mag 2020
Assign those varibles as output arguments
function [u,data2,x_data]=AdvDiff
m=0;
x=linspace(0,1,10);
t=linspace(0,1,10);
sol = pdepe(m,@AdvDiffpde,@AdvDiffic,@AdvDiffbc,x,t);
% Extract the first solution component as u.
u = sol(:,:,1);
% A surface plot
surf(x,t,u)
title('Advection Diffusion')
xlabel('Distance,x')
ylabel('Time,t')
zlabel('Concentration,C')
% A solution profile
figure
data2=u(end,:);
plot(x,data2);
title('Advection Diffusion')
xlabel('Distance,x')
ylabel('Concentration,C')
grid on
axis tight
end
Call the dunctions with output arguments (Make all variable as output arguments, those data you needed in the currect working directory)
Example:
>> [u,data2,x_data]=AdvDiff
u =
1.0000 0.8948 0.8007 0.7165 0.6412 0.5738 0.5134 0.4594 0.4111 0.3679
0.8889 0.8584 0.8154 0.7624 0.7018 0.6356 0.5652 0.4908 0.4119 0.3270
0.7778 0.7671 0.7441 0.7092 0.6632 0.6067 0.5401 0.4642 0.3793 0.2861
0.6667 0.6657 0.6528 0.6279 0.5911 0.5427 0.4832 0.4131 0.3334 0.2453
0.5556 0.5612 0.5552 0.5376 0.5083 0.4677 0.4161 0.3544 0.2834 0.2044
0.4444 0.4560 0.4562 0.4451 0.4229 0.3899 0.3466 0.2938 0.2323 0.1635
0.3333 0.3509 0.3573 0.3527 0.3375 0.3121 0.2771 0.2331 0.1812 0.1226
0.2222 0.2461 0.2589 0.2610 0.2529 0.2351 0.2082 0.1730 0.1305 0.0818
0.1111 0.1418 0.1614 0.1704 0.1695 0.1592 0.1404 0.1138 0.0803 0.0409
-0.0000 0.0381 0.0648 0.0810 0.0874 0.0847 0.0738 0.0554 0.0305 0
data2 =
-0.0000 0.0381 0.0648 0.0810 0.0874 0.0847 0.0738 0.0554 0.0305 0
x_data =
0 0.1111 0.2222 0.3333 0.4444 0.5556 0.6667 0.7778 0.8889 1.0000
Now output aruguments are avalible in workspace, thease variable are avalible outside if the function also
See the function file, if you execute the main code without function file, all varible are avalible in workspace. Suggested tho see the documentation (Matlab Function Declaration) and another way define those variables as global variables, please go through this.
Any issue let me know
  1 Commento
Adrian Oblena
Adrian Oblena il 2 Mag 2020
This is really a great help. Thank you very much.

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Migrate GUIDE Apps in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by