Info

此问题已关闭。 请重新打开它进行编辑或回答。

How do I calculate equation sets of 3 unknown x,y,z given csv. file with 30 different sets of equations?

1 次查看(过去 30 天)
Hi I'm fairly new to Matlab and I'm having issues figuring out how to solve this problem: Given a csv. file with 90 rows of values (ex. -38,-16,40,-19), each representing a part of an equation set of 3 (that means 3x30 sets of equations). I'm asked to return the equations in the first output of the function, and the following answer in the second output. Is there a fast, neat way to solve this? Please help
  1 个评论
John D'Errico
John D'Errico 2016-10-6
Just use a loop. Fast. Efficient. Simple to write. There is no reason to need to make this vectorized. Sometimes people want to see a nice expression that magically does what you want. But too often that one line expression is impossible to read. It works, but why bother here?

回答(1 个)

Hoai Tran Quoc
Hoai Tran Quoc 2016-10-7
Hope it helps you.
a = csvread('testEQdata.csv');
X = zeros(90,1);
for i = 1:30
A = a((i-1)*3+1:(i-1)*3+3,1:3);
B = a((i-1)*3+1:(i-1)*3+3,4);
X((i-1)*3+1:(i-1)*3+3,1) = linsolve(A,B);
end
disp(X);

Community Treasure Hunt

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

Start Hunting!

Translated by