[英]How can I find the index of the last greater than or equals value in one array, for all values in the first array? MATLAB
[英]How to find all values greater than 0 in a cell array in Matlab
我想在數組中查找並保存所有大於0的值,並將它們保存在名為“ times”的變量中。 我怎么做? 保存這些單元格的索引與單元格的實際值之間有什么區別?
這是我嘗試過的方法,但是由於我得到了錯誤,因此必須將其磨損:
類型為“ cell”的輸入參數的未定義運算符“>”。
clear all, close all
[num,txt,raw] = xlsread('test.xlsx');
times = find(raw(:,5)>0)
要訪問單元格的內容 ,必須使用{}
而不是()
:
idx = find([raw{:, 5}] > 0);
但這為您提供了包含正值的raw
單元格的索引 。 如果需要這些值 ,則可以通過以下方式訪問它們並將它們收集在數字數組中:
times = [raw{idx, 5}];
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.