Function calls of both script and Inline variety

i am creating a code where i need a 2d and 3d matrix , then i each one to be manipulated. which i did fine, not i need to call both scipts and inline variety. i am have trouble but here is my code. any help?
clear all;
close all;
clc;
disp('The 2D matrix is:')
A = [0 11 2; 1 1 5; 1 17 8]
A(:,:,2) = [10 11 12; 13 14 15; 16 17 18]
% display matrix A 2D Matrix
disp('The 3D matrix is:')
B = cat(3,A,[10 13 4; 0 9 8; 5 3 7])
% display matrix B 3D Matrix
disp('Matrix B permutated:')
C = permute(B,[3 2 1])
disp('Matrix A transposed:')
D = flip(A)
funct1=inline ('D+C^x','x'))
i get the following errors
Error using vectorize
Too many input arguments.
Error in displayfunction (line 21)
funct1=inline (vectorize('x^2','x'))
displayfunction
Error: File: displayfunction.m Line: 21 Column: 29
Invalid expression. When calling a function or indexing a variable, use parentheses. Otherwise, check for mismatched delimiters.

3 件のコメント

Stephen23
Stephen23 2020 年 5 月 28 日
編集済み: Stephen23 2020 年 5 月 28 日
funct1=inline ('D+C^x','x'))
Note the unmatched parentheses and that this line does not match what the error message shows.
The top of of the inline documentation states in bold:
"inline is not recommended. Use Anonymous Functions instead."
You should follow the advice given in the MATLAB documentation and avoid outdated, almost obsolete inline.
Keisteria Battle
Keisteria Battle 2020 年 5 月 28 日
I have to learn to use the inline function for a project but removing a parentheses helped . Thank you.
Steven Lord
Steven Lord 2020 年 5 月 28 日
I have to learn to use the inline function for a project
Unless that project is to convert some older code that uses inline to use anonymous functions instead, I'd push back on whomever is asking you to use inline. In particular, what you're trying to do is very difficult with inline but basically trivial with anonymous functions.
A = 2;
B = 3;
C = @(x) A*x.^B;
C(5) % 2*5^3 = 250

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

 採用された回答

madhan ravi
madhan ravi 2020 年 5 月 28 日
編集済み: madhan ravi 2020 年 5 月 28 日

1 投票

There’s one additional “)” in the inline(...) function. Remove it.

2 件のコメント

Keisteria Battle
Keisteria Battle 2020 年 5 月 28 日
thank you .
madhan ravi
madhan ravi 2020 年 5 月 28 日
編集済み: madhan ravi 2020 年 5 月 28 日
Also make note of Stephan comment above as well. A useful comment.

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeFunction Creation についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by