Reputation: 11
I need to multiply three matrices (X, Y and Z) together in Scilab. I have 100 versions of matrix Z to populate with data from an excel file and I need to multiply XYZ for each version, I am fine doing it for one matrix but I cannot get the process to repeat 100 times. Matrix Z has 7 columns so at the moment my code looks something like this:
Trial = read_csv("Testrun2.csv")
index = 0
while index<100
Z=[msprintf(Trial(1+(index*7),2)) msprintf(Trial(2+(index*7),2))...
Test = Z.*Y.*X
disp(index);
index = index + 1;
end
I have looked online but can find nothing that works, any help would be appreciated.
Thanks
Dan
Upvotes: 1
Views: 165
Reputation: 615
If you use msprintf
that will produce a string which can not be multiplied with a number: "2"*2
will give an error. To convert a string to a number you can use strtod
and I think its better to do in the beginnig e.g.
T=strtod(Trial);
After that you can index T
in a usual way, e.g.
Z=T(1:3,1:3);
Another possible solutions:
1.) read_csv
have a string matrix output by default, but you can change it to double if you want (see help for read_csv
).
2.) If you use csvRead
its default mode is double, see https://help.scilab.org/docs/5.5.1/en_US/read_csv.html
Upvotes: 1