excel - 如何将所需数据从 excel 文件中检索到 matlab (R2015 a) 中?
问题描述
function sample()
[FileName,FilePath]=uigetfile();
ExPath = [FilePath FileName];
f=xlsread(ExPath);
[R C]=size(f);
disp(R);
disp(C);
Y=f(R+1:R:R*C);
X=f(2:1:R);
Z=f(2:1:R,2:1:C);
disp(Y);
上面是一个从excel文件中读取数据的示例代码。我不知道索引是如何完成的。
disp(Y) 似乎输出了第一行的值。
谁能解释一下上述索引是如何工作的。
解决方案
Matlab 按列存储 n 维数组,然后是行,然后是每个更高的维度。
f = [1 2; 3 4]; ' an example
f(1,1); ' returns 1
f(2,1); ' returns 3
f(1,2); ' returns 2
f(2); 'returns 3
f(1,:); ' returns [1 2]
f(2,1:1:2); 'returns [3 4];
f(:,1); 'returns [1; 3]
f(1:1:4); 'returns [1 3 2 4]
f(f>1); 'returns [3 2 4]
f(R+1:R:R*C); 'returns 2 - the first row starting at the 2nd column.
推荐阅读
- ios - 嵌入 UITableView 时 UISwitch 动画损坏
- javascript - 在我的 Angular 6 项目中,我放置了 GOjs 库,它给出了 TS 编译错误
- android - 移除 Facebook Developer App Dashboard 下的“user_friends”权限
- fortran - Fortran do loop not calculating the entered variable
- python - Pandas to_sql - 附加 DataFrame 时增加表的索引
- ruby-on-rails - Rails 初始化程序未配置 DelayedJob Worker
- reactjs - [React Final Form] 是否适用于 Material-UI 3.x?
- angular - 订阅 route.queryParamMap 和 route.paramMap 导致页面加载两次
- angular - 这是怎么回事?PhpStorm 10.0.1 和 Angular
- sql-server - SQL 过程在通过 Java 执行时导致数据库锁定