필터 지우기
필터 지우기

I got error in this script

조회 수: 1 (최근 30일)
NANDEESWARAN
NANDEESWARAN 2023년 10월 3일
편집: the cyclist 2023년 10월 3일
clear,clc,close all
datas = readtable('time_vs_load.xlsx','Sheet',2,'NumHeaderLines',1);
time = datas(:,1);
load = datas(:,2);
h = mean(diff(time));
n = length(load);
Error using tabular/length
Undefined function 'LENGTH' for input arguments of type 'table'. Use the height, width, or size functions instead.
% Peak Loading Rate Using Central Difference formula
peak_l_r =(-3*load(1) + 4*load(2) - load(3))/(2*h);
for i = 2:n-1
peak_l_r = (load(i+1)-load(i-1))/(2*h);
end
peak_l_r = (load(n-2)-4*load(n-2) + 3*load(n))/(2*h);
peak_l_r = max(peak_l_r)
pear_loading_rate = peak_l_r
% Impulse during the entire timeseries using Trapezoidal methods
impulse = trapz(time,load)
% Results
disp(['Peak loading rate: ', num2str(peak_loading_rate)]);
disp(['Impulse: ', num2str(impulse)]);

채택된 답변

the cyclist
the cyclist 2023년 10월 3일
편집: the cyclist 2023년 10월 3일
The line
time = datas(:,1);
will give a table with one variable. You need to use curly brackets in access the contents of the table column.
time = datas{:,1};
This code works (after I fixed the typo "pear_loading_rate"):
clear,clc,close all
datas = readtable('time_vs_load.xlsx','Sheet',2,'NumHeaderLines',1);
time = datas{:,1};
load = datas{:,2};
h = mean(diff(time));
n = length(load);
% Peak Loading Rate Using Central Difference formula
peak_l_r =(-3*load(1) + 4*load(2) - load(3))/(2*h);
for i = 2:n-1
peak_l_r = (load(i+1)-load(i-1))/(2*h);
end
peak_l_r = (load(n-2)-4*load(n-2) + 3*load(n))/(2*h);
peak_l_r = max(peak_l_r)
peak_l_r = -1.6280e+04
peak_loading_rate = peak_l_r
peak_loading_rate = -1.6280e+04
% Impulse during the entire timeseries using Trapezoidal methods
impulse = trapz(time,load)
impulse = 884.2424
% Results
disp(['Peak loading rate: ', num2str(peak_loading_rate)]);
Peak loading rate: -16280.0583
disp(['Impulse: ', num2str(impulse)]);
Impulse: 884.2424
  댓글 수: 1
NANDEESWARAN
NANDEESWARAN 2023년 10월 3일
Thanks sir. I appreciate your help

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Signal Generation and Preprocessing에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by