# how to know the array of the function that i plot

1 view (last 30 days)
Momen Odeh on 25 May 2020
Edited: Ameer Hamza on 25 May 2020
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
Momen Odeh on 25 May 2020
The string will be the function y, 'eval(y)' , it will be an array so i used arrays element multiplication

Ameer Hamza on 25 May 2020
Edited: Ameer Hamza on 25 May 2020
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);

Image Analyst on 25 May 2020
Make sure you use .* instead of just * alone:
vec1 = function1();
vec2 = function2();
theProduct = vec1 .* vec2;
Momen Odeh on 25 May 2020
I did