[Scilab-users] Hypermatrix manipulation

Rafael Guerra jrafaelbguerra at hotmail.com
Tue Nov 17 22:38:23 CET 2015


Hi Petar,
 
If you only need to write the hypermatrix M to disk you could do:
 
M=rand(100,3,3,3);  // example
[nx,ny,nz,nk]= size(M);
fid = mopen("hyper_out.txt",'w');
mfprintf(fid,"%i  %i  %i  %i\n",nx,ny,nz,nk);
for i=1: length(M)
    mfprintf(fid,"%15.5f\n",M(i));
end;
mclose(fid)
 
You need to adapt output format to your needs, which you did not specify. For
example, to read the above file in Scilab, you could do:
 
fid = mopen("hyper_out.txt",'r');
str = mgetl(fid,1);
M= mfscanf(-1,fid,"%f");
mclose(fid)
x= evstr(str);
nx=x(1); ny=x(2); nz=x(3); nk=x(4);
M= matrix(M,nx,ny,nz,nk);
 
 
Regards,
Rafael
 
-----Original Message-----
From: users [mailto:users-bounces at lists.scilab.org] On Behalf Of petarf
Sent: Tuesday, November 17, 2015 8:23 PM
To: users at lists.scilab.org
Subject: Re: [Scilab-users] Hypermatrix manipulation
 
Dear Rafael,
 
My matrix is already defined  M(50,3,3,3). These numbers depends on user
input. It could be 100 instead 50. And also matrix is already filled.
Because of this i have trouble with part where you define x,y,.. variables
and later you call them in mfprintf function. 
 
Is there any possibility that I write only specific part of hypermatrix?
 
Regards, Petar
 
 
 
 
--
View this message in context:
<http://mailinglists.scilab.org/Hypermatrix-manipulation-tp4033098p4033101.html>
http://mailinglists.scilab.org/Hypermatrix-manipulation-tp4033098p4033101.html
Sent from the Scilab users - Mailing Lists Archives mailing list archive at
Nabble.com.
_______________________________________________
users mailing list
 <mailto:users at lists.scilab.org> users at lists.scilab.org
 <http://lists.scilab.org/mailman/listinfo/users>
http://lists.scilab.org/mailman/listinfo/users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.scilab.org/pipermail/users/attachments/20151117/7f4853f6/attachment.htm>


More information about the users mailing list