a simple calculation by each row
Show older comments
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)))
solx = vpasolve(eqn,x)
2 Comments
Jan
on 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
on 3 Oct 2022
Accepted Answer
More Answers (0)
Categories
Find more on Calculus 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!
