フィルターのクリア

Basic programming, can't figure out where the problem is.

1 回表示 (過去 30 日間)
Kevin Brinneman
Kevin Brinneman 2018 年 10 月 27 日
コメント済み: Kevin Brinneman 2018 年 10 月 27 日
Hello everyone,
I am writing a function that will solve a simple linear equation and I was just testing the inputs when this error came up and still can't find what the problem is. When calling the function I am using exactly the command an as many inputs and I have defined in the function but still no luck. Here's my code:
function [outputArg1,outputArg2] = problemSolver_one(m1,m2,r,g,x1,x2,x3,x4)
x1_dot=input('Enter state x1_dot')
x2_dot=input('Enter state x2_dot')
x3_dot=input('Enter state x3_dot')
x4_dot=input('Enter state x4_dot')
(m1*m2*r*g) = outputArg1
(x1*x2*x3*x4) = outputArg2
return
end
And this is what I type in to call the function:
>> problemSolver_one=(1,2,3,4,5,6,7,8)
and the error that I get:
problemSolver_one=(1,2,3,4,5,6,7,8)
Error: Invalid expression. When calling a function or indexing a variable, use parentheses. Otherwise, check for
mismatched delimiters.
Thank you for your time!
  3 件のコメント
Kevin Brinneman
Kevin Brinneman 2018 年 10 月 27 日
that is just a simple multiplicatipon that i am using to test that the function is taking the inputs.
Image Analyst
Image Analyst 2018 年 10 月 27 日
Did you see Walter's answer below that corrected your code?

サインインしてコメントする。

採用された回答

Walter Roberson
Walter Roberson 2018 年 10 月 27 日
編集済み: Walter Roberson 2018 年 10 月 27 日
Call it with
[output1, output2] = problemSolver_one(1,2,3,4,5,6,7,8)
and as jonas points out, change your code
outputArg1 = (m1*m2*r*g)
outputArg2 = (x1*x2*x3*x4)
  1 件のコメント
Kevin Brinneman
Kevin Brinneman 2018 年 10 月 27 日
Thank you very much Walter! It worked.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

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