フィルターのクリア

I need help with an error I get

1 回表示 (過去 30 日間)
Nathanael
Nathanael 2024 年 5 月 5 日
編集済み: Venkat Siddarth Reddy 2024 年 5 月 5 日
I have to write a bit of code for an assignment and I keep getting an error and I dont know how to solve it.
I have to determine the position, velocity and acceleration. funcao_forca is a function of a force that is defined in another script. It keeps telling me that F is not recognized. How do I go about this?
function [posicao, velocidade, aceleracao] = atleta(t, f, M)
f = funcao_forca(t,F);
dt = 1;
t1 = [0:dt:t];
aceleracao = zeros(size(t1));
aceleracao = f/M;
velocidade = zeros(size(t1));
for i = 2:length(t1)
velocidade(i) = velocidade(i-1) + aceleracao(i) * (t1(i) - t1(i-1));
end
posicao = zeros(size(t1));
for i = 2:length(t1)
posicao(i) = posicao(i-1) + velocidade(i-1) + 0.5 * aceleracao(i) * (t1(i) - t1(i-1))^2;
end
end

採用された回答

Stephen23
Stephen23 2024 年 5 月 5 日
Perhaps the input argument should be F (not f):
function [posicao, velocidade, aceleracao] = atleta(t, F, M)

その他の回答 (2 件)

Torsten
Torsten 2024 年 5 月 5 日
移動済み: Torsten 2024 年 5 月 5 日
Define F before you call "funcao_forca". It's not set in your code.
Maybe you mean
F = funcao_forca(t,f);
because f is a given input to your function.

Venkat Siddarth Reddy
Venkat Siddarth Reddy 2024 年 5 月 5 日
編集済み: Venkat Siddarth Reddy 2024 年 5 月 5 日
Hi Nathanael,
Variables in MATLAB are case-sensitive.In the first line of function definition, "F" has been used which isn't declared or defined before. I think you have accidentally typed it for the variable "f".
I hope it helps!

カテゴリ

Help Center および File ExchangeProgramming についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by