How to extract data from a file, and form a column vector?
조회 수: 7 (최근 30일)
이전 댓글 표시
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
채택된 답변
추가 답변 (1개)
Stephen23
2024년 3월 18일
편집: Stephen23
2024년 3월 18일
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
참고 항목
카테고리
Help Center 및 File Exchange에서 Structures에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!