回覆列表
  • 1 # 得到歷史

    matlab中怎麼把logical臨行的矩陣轉化為double型別double(A) 即可實現Matlab中什麼是logicallogical作為邏輯變數,可以是一種資料型別,第一次見到是在workspace裡100*1logical,可以用在取出最值。logical是布林變數,可以是一個標量,也可以是一個向量或者是矩陣。可以用作下標。在幫助文件中給出了一個例子:A = [1 2 3; 4 5 6; 7 8 9]要想取出對角元素,可以用diag(A),也可以藉助下標。構建一個logical矩陣,或者說是下標矩陣 logical(eye(3))T=eye(3)是3*3單位陣logical(T)是把為真(1)的值取出即:eye(3)=[1 0 0; 0 10; 0 01;]A(logical(eye(3))的意思是取出下標為真的元素:最終返回:[1;5;9]; 參考:

    http://blog.csdn.net/waleking/article/details/7270156

    求極值clear;N = 100;v = rand (N,1);t = 0:length(v)-1;Lmax = diff(sign(diff(v)))== -2; % logic vector for the local max valueLmin = diff(sign(diff(v)))== 2; % logic vector for the local min value% match the logic vector to the original vecor to have the same lengthLmax = [false; Lmax; false];Lmin = [false; Lmin; false];tmax = t (Lmax); % locations of the local max elementstmin = t (Lmin); % locations of the local min elementsvmax = v (Lmax); % values of the local max elementsvmin = v (Lmin); % values of the local min elements % plot them on a figureplot(t,v);xlabel("t"); ylabel("v");hold on;plot(tmax, vmax, "r+");plot(tmin,vmin, "g+");hold off;

  • 中秋節和大豐收的關聯?
  • 魔獸動漫《我叫MT》被騰訊做成手遊,6小時登頂免費榜首,對此你怎麼看?