MATLAB Answers

Dynamic array for string

4 views (last 30 days)
Temidayo BOBOYE
Temidayo BOBOYE on 13 May 2020
Edited: Mehmed Saad on 13 May 2020
D = 0.067;
Ugs = [0.047,0.061,0.288,0.344,0.404,0.544,0.709,0.945,1.418,1.891,2.363,2.836,4.727];
Uls = ones(1,13)*0.047;
L = 6.0000;
g = 9.81;
% Um=zeros(Ugs.size);
Um = Ugs + Uls;
Le = 42.6 * D *((Um/((g*D)^0.5))+0.29);
for i = 1:13
if L < Le:13
flow='churn'
else
if L >= Le:13
flow='slug'
arrow(i,:) = flow;
end
end
end
Ugs = Ugs.';
Le = Le.';
Um = Um.';
flow = flow.';
Uls = Uls.';
P = plot(Le,Um)
T = table(Uls,Ugs,Le,Um,arrow)

  0 Comments

Sign in to comment.

Accepted Answer

Mehmed Saad
Mehmed Saad on 13 May 2020
Edited: Mehmed Saad on 13 May 2020
cells are used for that purpose
arrow{i} = flow;% braces changed
Take transpose of arrow like you are doing for other variables
also this line will give you error.
if L >= Le:13
for indexing replace Le:13 with Le(i)
the final table you will get is
T =
13×5 table
Uls Ugs Le Um arrow
_____ _____ ______ _____ _______
0.047 0.047 1.1587 0.094 'slug'
0.047 0.061 1.2079 0.108 'slug'
0.047 0.288 2.0071 0.335 'slug'
0.047 0.344 2.2043 0.391 'slug'
0.047 0.404 2.4155 0.451 'slug'
0.047 0.544 2.9084 0.591 'slug'
0.047 0.709 3.4893 0.756 'slug'
0.047 0.945 4.3201 0.992 'slug'
0.047 1.418 5.9853 1.465 'slug'
0.047 1.891 7.6506 1.938 'churn'
0.047 2.363 9.3123 2.41 'churn'
0.047 2.836 10.978 2.883 'churn'
0.047 4.727 17.635 4.774 'churn'

  0 Comments

Sign in to comment.

More Answers (0)

Products


Release

R2019b

Translated by