how to know the array of the function that i plot

hi everyone,
i need some a little help to complete my project, it is not hard but when i make the user enter a function in GUI and plot it alone it works but when i try to multiply it with another function it doesnt work.
also how i can know how to find the array that the matlab calculated for my function
thank for you all

4 件のコメント

Ameer Hamza
Ameer Hamza 2020 年 5 月 25 日
How are you trying to multiply the functions? You cannot multiply function handles in MATLAB, so you need to call the function with input arguments to multiply.
Momen Odeh
Momen Odeh 2020 年 5 月 25 日
I mean with function f(x) not the matlab function
Ameer Hamza
Ameer Hamza 2020 年 5 月 25 日
But how are you converting the string entered in GUI to a function and then multiply them?
Momen Odeh
Momen Odeh 2020 年 5 月 25 日
The string will be the function y, 'eval(y)' , it will be an array so i used arrays element multiplication

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

 採用された回答

Ameer Hamza
Ameer Hamza 2020 年 5 月 25 日
編集済み: Ameer Hamza 2020 年 5 月 25 日

0 投票

See this example to convert to strings to function handles and multiply them
y1 = 'sin(x)';
y2 = 'cos(x)';
y1f = str2func(['@(x) ' y1]);
y2f = str2func(['@(x) ' y2]);
y = @(x) y1f(x).*y2f(x);

その他の回答 (1 件)

Image Analyst
Image Analyst 2020 年 5 月 25 日

0 投票

Make sure you use .* instead of just * alone:
vec1 = function1();
vec2 = function2();
theProduct = vec1 .* vec2;

カテゴリ

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

質問済み:

2020 年 5 月 25 日

編集済み:

2020 年 5 月 25 日

Community Treasure Hunt

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

Start Hunting!

Translated by