2012-05-29 135 views
0

我有一個方程f(β) = cosh β cos β + 1 = 0,我需要使用βi根來找到一些頻率。對於頻率的公式是在matlab中使用牛頓方程

fi = sqrt((βi^4 * E*I)/(4*pi*m*L^3)); 

我得到這個錯誤,我不知道問題出在哪裏

??? Subscript indices must either be real positive integers or logicals. 

Error in ==> C:\Documents and Settings\Laura Lupas\Desktop\subiect88\frecventa.m 
On line 18 ==>  p= p0 - f(p0)/fd(p0); 

這裏是我的代碼:

function p = frecventa(f,fd,p_start,eps); 

    p0=p_start; 
    i=1; 

    L = 0.9; %lungimea grinzii in m 
    b = 0.025; %latimea grinzii in metri 
    h = 0.0025; %inaltimea in metrii 
    dens = 7850; % kg/m cub 
    v = b * h * L ; % volum 
    m = dens * v; 


    E = 2000e11; %modulul de elasti N/m patrat 
    I= (b*h^2)/12;%mometul de inertie 

    while(i <= 2) 
    p= p0 - f(p0)/fd(p0); 
    if abs(p-p0) < eps 
     return 
    end 
     i = i + 1; 
     p0=p; 

     p = sqrt((p0^4 * E*I)/(4*pi*m*L^3)) 
    end  



    % beta = 0:0.001:pi 
    %f = cosh(beta).*cos(beta) + 1; 
    %fd = sinh(beta).*cos(beta) - cosh(beta).*sin(beta); 
+0

您是否設法解決該問題? – mathematician1975

回答

0

難道只是

% beta = 0:0.001:pi 
    %f = cosh(beta).*cos(beta) + 1; 
    %fd = sinh(beta).*cos(beta) - cosh(beta).*sin(beta); 

應該是ab剩下的代碼,並取消註釋?

那麼試試這個:

beta = 0:0.001:pi 
    f = cosh(beta).*cos(beta) + 1; 
    fd = sinh(beta).*cos(beta) - cosh(beta).*sin(beta); 
    p0=p_start; 
    i=1; 

    L = 0.9; %lungimea grinzii in m 
    b = 0.025; %latimea grinzii in metri 
    h = 0.0025; %inaltimea in metrii 
    dens = 7850; % kg/m cub 
    v = b * h * L ; % volum 
    m = dens * v; 


    E = 2000e11; %modulul de elasti N/m patrat 
    I= (b*h^2)/12;%mometul de inertie 

    while(i <= 2) 
    p= p0 - f(p0)/fd(p0); 
    if abs(p-p0) < eps 
     return 
    end 
     i = i + 1; 
     p0=p; 

     p = sqrt((p0^4 * E*I)/(4*pi*m*L^3)) 
    end  
0

如果ffd是您作爲輸入參數來你的功能,你可能會在更新後的參數p0=p傳遞作爲索引到這些載體中的載體。您的代碼顯示您正在計算p= p0 - f(p0)/fd(p0);,後來在循環更新p0pp(因此爲p0)的這種假設涉及分割步驟,因此不可能產生p0的整數值結果。由於這是ffd索引索引的值,它將解釋您收到的錯誤消息,很明顯,您不能在矩陣或向量中包含非整數索引。