MATLAB matrices, vectors, and equations help!!!

I'm currently trying to compute values of two different Variables, but the problem is that, while one equation is working, the other isn't. Here is my current code with my matrices included.
INITIAL MATRICES/ VECTORS:
X =
NaN
0.2200
0.3000
0.4400
0.4900
0.7000
0.8000
0.9000
1.1000
1.0000
1.1500
1.2000
1.2200
1.2600
1.2500
1.2700
1.2000
1.2200
1.2600
1.2000
1.2200
1.2600
1.2000
1.2200
1.2600
1.2500
t =
NaN
0
4
7
10
13
16
22
25
30
33
36
40
48
51
55
60
80
100
120
140
160
180
200
220
240
%% Problem 1
%{
X=Cell Mass Concentration (g/L)
U= Cell Mass Yield Per Carbon Monoxide gcells/mmolCO
t= Time (hours)
Mu= Specific Growth Rate
X1=X(1:end-1)
X2=X(2:end)
t1=t(1:end-1)
t2=t(2:end)
Mu=(X2-X1)/(t2-t1)
U=(X2-X1)/CO
%}
X1=X(1:end-1)
X2=X(2:end)
t1=t(1:end-1)
t2=t(2:end)
Mu=(log(X2)-log(X1))./(t2-t1);
U=(X2-X1)/CO;
%{
ans
Max value of Cell Mass Yield per Carbon Monoxide = max(Yx)
Max value of Cell Mass Concentration = max(Mu)
%}
% Find max values of specific growth rate(Mu) and cell mass yield(Yx/co)
Mumax=max(Mu);
Umax=max(U);
% Answer Display
sprintf('The maximum specific growth rate is %f, and the maximum cell mass yield per CO is %f',Mumax, Umax)
The problem with my current code is that, while Mu is equalling a vector which 26x1, U is equalling a matrix which is 25x26. I need U to also be a 26x1 vector, because currently my max value for U is 0.00000.

 채택된 답변

Star Strider
Star Strider 2019년 11월 25일

1 개 추천

The ‘CO’ variable is missing.
If ‘CO’ is a row vector rathar than a column vector, that could be the problem. If so, the solution would be to transpose it to a column vector. Remember to do element-wise operations, if that is what you want.

댓글 수: 4

Grace Rembold
Grace Rembold 2019년 11월 25일
CO is a column vector just like X and t.
CO =
NaN
0
7.7100
11.2600
13.9200
19.8000
21.2500
20.1300
20.9100
21.3900
21.9900
23.8700
22.2700
22.7300
22.2400
22.3100
22.2300
21.9300
22.6000
22.0100
21.8100
21.5600
21.6000
20.6200
19.1700
18.8700
also, I'm very bad at using MATLAB. My first version of this code worked fine, and there was a "." in the equation somewhere i just have no idea where.
This produces a (25x1) vector:
U=(X2-X1)./CO(2:end);
That is likely where the dot operator was, however the sizes of the vectors must also be the same.
I do not completely understand what you are doing, especially with respect to ‘X1’ and ‘X2’, and ‘t1’ and ‘t2’.
Grace Rembold
Grace Rembold 2019년 11월 25일
Thank you, that is where the dot operator was.
the t1, X1, etc. have been removed for everything now. they were just placeholders that made it easier to read while i figured out the actual equation. I'm basically recreating a given equation based off of excel data and then using the equations to plot relationships between the data. in further problems. But to be honest, i'm nto really sure whats going on either :/
Star Strider
Star Strider 2019년 11월 25일
My pleasure.
If my Answer helped you solve your problem, please Accept it!

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Logical에 대해 자세히 알아보기

제품

릴리스

R2019b

질문:

2019년 11월 25일

댓글:

2019년 11월 25일

Community Treasure Hunt

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

Start Hunting!

Translated by