How to extract data from a file, and form a column vector?
7 views (last 30 days)
Show older comments
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!
0 Comments
Accepted Answer
More Answers (1)
Stephen23
on 18 Mar 2024
Edited: Stephen23
on 18 Mar 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(:)
Note that EXPERIMENT1 is unused.
0 Comments
See Also
Categories
Find more on Structures in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!