matlab tensor张量库的安装与测试

1)matlab tensor张量库的安装

     最新版本 Tensor Toolbox 2.6,下载地址:http://www.sandia.gov/~tgkolda/TensorToolbox/index-2.6.html下载之前需要简单的注册一下,提交相关的使用者基本信息,点击提交后直接跳转到下载页面,下载即可,有zip和tar.gz格式。http://www.sandia.gov/~tgkolda/TensorToolbox/thankyou-2.6.html

Download

Installation

  1. Unpack the files.
  2. Rename the root directory of the toolbox from tensor_toolbox_2.6 to tensor_toolbox.
  3. Start MATLAB.
  4. Within MATLAB, cd to the tensor_toolbox directory and execute the following commands. 

    addpath(pwd) %<-Add the tensor toolbox to the MATLAB path
    cd met; addpath(pwd) 
    %<-- Also add the met directory
    savepath 
    %<-- Save for future MATLAB sessions

安装的具体方法是:

(1).解压当前安装包;

(2).将 tensor_toolbox_2.6 改名为 tensor_toolbox

(3).启动matlab,选择toolsbox所在的路径,然后在matlab的命令窗口中键入如下命令:

[plain]  view plain  copy  print ? 在CODE上查看代码片 派生到我的代码片
  1. addpath(pwd) %将当前路径添加到matlab工作路径中去  
  2. cd met; addpath(pwd) %将子目录met也添加进来  
  3. savepath %为后续进程保存这两个路径  

2)张量的测试

%创建一个4*3*2的一个张量,元素都为 1

>> M = ones(4,3,2); %<-- A 4 x 3 x 2 array.
X = tensor(M) %<-- Convert to a tensor object.
X is a tensor of size 4 x 3 x 2
X(:,:,1) = 
    1     1     1
    1     1     1
    1     1     1
    1     1     1
X(:,:,2) = 
    1     1     1
    1     1     1
    1     1     1
    1     1     1

>> X = tensor(rand(5,1)) %<-- Creates a 2-way tensor.
X is a tensor of size 5 x 1
X(:,:) = 
   0.0821
   0.1057
   0.1420
   0.1665
   0.6210
>> Y = tensor(rand(4,3,1)) %<-- Creates a 2-way tensor.
Y is a tensor of size 4 x 3
Y(:,:) = 
   0.5737    0.7378    0.9844
   0.0521    0.0634    0.8589
   0.9312    0.8604    0.7856
   0.7287    0.9344    0.5134

 X = tenrand([4 3 2]); %<-- Create data.

X.data %<-- The array.
ans(:,:,1) =
    0.0971    0.9502    0.7655
    0.8235    0.0344    0.7952
    0.6948    0.4387    0.1869
    0.3171    0.3816    0.4898
ans(:,:,2) =
    0.4456    0.2760    0.1190
    0.6463    0.6797    0.4984
    0.7094    0.6551    0.9597
    0.7547    0.1626    0.3404

>> X.size %<-- The size.


ans =

     4     3     2

最后,介绍一个matlab 的tensorlab库,官网http://www.tensorlab.net/也非常不错,最新更新2016年

  • 4
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

failwest9527

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值