Borrar filtros
Borrar filtros

How to extract data from a file, and form a column vector?

4 visualizaciones (últimos 30 días)
Sergio
Sergio el 18 de Mzo. de 2024
Comentada: Voss el 19 de Mzo. de 2024
Take the four files, and run "test.m" in MATLAB. It generates the relative concentrations of Substrate and product as label "SP".
The first experiment gives:
SUBSTRATE (SP first value): 0.98
PRODUCT (SP second value): 2.11
The second generated from test.m gives:
SUBSTRATE: 0.52
PRODUCT: 1.57
The third:
e)
SUBSTRATE: 0.24
PRODUCT: 0.85
and the fourth gives:
SUBSTRATE: 2.38
PRODUCT: 2.71
These are given in the output,
How can I subsbtract these values from the respective y0 values in the test.m output automatically and arrange the difference such as:
r= [ y_0 (first value, first experiment) - SP (first value first experiment,
y_0 (first value, second experiment)- SP (first value second experiment,
y_0 (first value, third experiment)- SP (first value third experiment ,
y_0 (first value, fourth experiment)- SP (first value fourth experiment,
y_0 (second value, first experiment)- SP (second value first experiment ,
y_0 (second value, second experiment)- SP (second value second experiment,
y_0 (second value, third experiment)- SP (second value third experiment ,
y_0 (second value, fourth experiment)- SP (second value fourth experiment ]
These entries are respectively by the output of test:
2-0.98,
1-0.52,
1-0.24,
4-2.38,
1-2.11,
1-1.57,
0-0.85,
1-2.71
These would hence form a vector r=[1.02, 0.48, 0.76, 1.72, ...., -1.71]
Thanks!

Respuesta aceptada

Voss
Voss el 18 de Mzo. de 2024
See the attached test_modified for one way to do that.
test_modified
ans = 2×1
0.5249 1.5751
ans = 2×1
0.2476 0.8524
ans = 2×1
2.3875 2.7125
r = 1×8
1.0146 0.4751 0.7524 1.6125 -1.1146 -0.5751 -0.8524 -1.7125

Más respuestas (1)

Stephen23
Stephen23 el 18 de Mzo. de 2024
Editada: Stephen23 el 18 de Mzo. de 2024
Note that copy-and-pasting blocks of code like that... is not a generalized approach to writing code. Best avoided.
Rather than doing the computer's job by painstakingly copy-and-paste-and-modifying code like that, let the computer do that simple task by writing a loop. For example:
ym = [2,1;1,1;1,0;4,1];
dt = 0.01;
T = 1;
k = [5;1];
SP = nan(size(ym));
for ii = 1:size(ym,1)
y0 = ym(ii,:);
[SP(ii,:),~] = enzyme(y0,k,dt,T);
end
V = ym(:)-SP(:)
V = 8×1
1.0146 0.4751 0.7524 1.6125 -1.1146 -0.5751 -0.8524 -1.7125
Note that EXPERIMENT1 is unused.

Categorías

Más información sobre Startup and Shutdown en Help Center y File Exchange.

Productos


Versión

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by