Effacer les filtres
Effacer les filtres

a simple calculation by each row

2 vues (au cours des 30 derniers jours)
Deokjae Jeong
Deokjae Jeong le 3 Oct 2022
Modifié(e) : Torsten le 3 Oct 2022
I have 11 variables with each 24 rows. Therefore the data has 24x11 matrix.
I need to find out a vector x that is unknown. It is calculated each row by each row.
I believe this is really a simple task, but it gives me an error message. Could you fix my code?
The csv data is attached.
The code is below:
opts = delimitedTextImportOptions("NumVariables", 11);
opts.DataLines = [2, Inf];
opts.Delimiter = ",";
opts.VariableNames = ["v1","v2","w1","w2","u1","u2","LL","L1","R","eta","vl"];
opts.SelectedVariableNames = ["v1","v2","w1","w2","u1","u2","LL","L1","R","eta","vl"];
opts.VariableTypes = ["double","double","double","double","double","double","double","double","double","double","double"];
opts.ExtraColumnsRule = "ignore";
opts.EmptyLineRule = "read";
tbl = readtable("https://de.mathworks.com/matlabcentral/answers/uploaded_files/1144220/data.csv", opts);
v1 = tbl.v1;
v2 = tbl.v2;
w1 = tbl.w1;
w2 = tbl.w2;
u1 = tbl.u1;
u2 = tbl.u2;
LL = tbl.LL;
L1 = tbl.L1;
R = tbl.R;
eta = tbl.eta;
vl = tbl.vl;
clear opts tbl
x = sym('x',[24 1]);
eqn= w1(1:24).^(1./eta(1:24)).*((v1(1:24)+vl(1:24).*(x-L1(1:24)))./(u1(1:24)))==w2(1:24).^(1./eta(1:24)).*((v2(1:24)-vl(1:24).*x)./(u2(1:24)))
eqn = 
solx = vpasolve(eqn,x)
solx = struct with fields:
x1: 39849.098439839888039995580252118 x2: 31896.131131835614248409660424623 x3: 30623.46859228488599788098808533 x4: 34288.357365128718164252084030317 x5: 33218.449588363269704310607329214 x6: 38683.838907884258366654183935849 x7: 48498.709829085994064528936869907 x8: 53734.835565915578538534431637503 x9: 60971.254678305479099782365418956 x10: 60795.578490308419439506465520588 x11: 63598.645068871610104964068769523 x12: 73805.83241708308175855439464272 x13: 93493.202580227088226990711316688 x14: 92395.482938456487295586853293179 x15: 88114.171897603740990721877865897 x16: 94710.58237067927806753793595844 x17: 95519.94075011699982930537150245 x18: 104692.3361253001772882836097709 x19: 114727.61054921550579417687813943 x20: 105868.47733825101949217215380698 x21: 122616.33829033540168661425772284 x22: 111089.51657475909520158536228558 x23: 115853.95267280550435053918951603 x24: 147912.82705953864516362058769025
  2 commentaires
Jan
Jan le 3 Oct 2022
Whenever you mention an error message, post a copy of the complete message. It is easier to solve a problem than to guess, what the problem is ;-)
Deokjae Jeong
Deokjae Jeong le 3 Oct 2022
@Jan, sorry about that.
There is not any error message, but it just gives solution as below, which is empty.
solx =
struct with fields:
x1: [0×1 sym]
x2: [0×1 sym]
x3: [0×1 sym]
x4: [0×1 sym]
x5: [0×1 sym]
x6: [0×1 sym]
x7: [0×1 sym]
x8: [0×1 sym]
x9: [0×1 sym]
x10: [0×1 sym]
x11: [0×1 sym]
x12: [0×1 sym]
x13: [0×1 sym]
x14: [0×1 sym]
x15: [0×1 sym]
x16: [0×1 sym]
x17: [0×1 sym]
x18: [0×1 sym]
x19: [0×1 sym]
x20: [0×1 sym]
x21: [0×1 sym]
x22: [0×1 sym]
x23: [0×1 sym]
x24: [0×1 sym]

Connectez-vous pour commenter.

Réponse acceptée

Torsten
Torsten le 3 Oct 2022
Modifié(e) : Torsten le 3 Oct 2022
Take ^(1/eta) of both sides of the equations. You get linear equations in x. Solve them.
See solution above.
  2 commentaires
Deokjae Jeong
Deokjae Jeong le 3 Oct 2022
umm,.. it gives the same problem.
Torsten
Torsten le 3 Oct 2022
What problem ? The solutions are listed above ...

Connectez-vous pour commenter.

Plus de réponses (0)

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by