Borrar filtros
Borrar filtros

Please help me to solve error.

5 visualizaciones (últimos 30 días)
Harsh Pastakia
Harsh Pastakia el 16 de Feb. de 2023
Respondida: Sai el 3 de Mzo. de 2023
>> u = @(t)double(t>=0);
>> h = @(t)u(t-1)-u(t-3);
>> fplot(h,[0,4])
>> title('Rectagular Pulse')
>> xlabel('Time')
>> ylabel('Amplitude');
>> grid
>> syms h func
>> F(func) = int(1*exp(1j*func*h), h, -u/2, u/2);
Unary operator '-' is not supported for operand of
type 'function_handle'.
Hi Matlab forums, hope you are all having a good day.
If anyone could spare some time to help me,I have encounted the error called "Unary operator '-' is not supported for operand of type 'function_handle' in for loop function". Does it mean I cant have a negative added onto the functional handle which calculates the drag? I have been giving a image of the specifc formula's and such I am meant to use and told not to change them, so it leads me to a problem in my code. I have tried putting brackets around the drag, so it is -1*(drag) but this does not work with or without brackets. So I'm kind of stuck where the problem is other than line 36 in which matlab tells me. I've attatched my script as a file (renamed just for clarity) and pasted it here. I've also attatched an image of all the formula's and code provided to me which should (hopefully!) assist in diagnosing my error.
I apologise if this type of question has been answered before, I did do a search on the matlab answers page and could only find one problem that was slightly similar to mine.
Any and all help is greatly appreciated forum support, thank you in advance for helping me with my problem!!
  3 comentarios
Harsh Pastakia
Harsh Pastakia el 16 de Feb. de 2023
Like how??? Can you write for me.
Torsten
Torsten el 16 de Feb. de 2023
u is a function handle depending on t that you use as limit of integration for F(func). What does that mean ?

Iniciar sesión para comentar.

Respuestas (1)

Sai
Sai el 3 de Mzo. de 2023
I understand that you wanted to perform an integration for the expression with the defined limits.
u = @(t)double(t>=0);
h = @(t)u(t-1)-u(t-3);
From the given code fragment, it can be seen that the function that handles 'u' and 'h' depends on the variable 't'.
For ‘u’, t: 0 to inf
For ‘h’ t: 1 to 3
Hence ‘u’ and ‘h’ cannot be used as integration limits.
The usage of function handles as integration limits is not permitted, hence the error.
Try running the same code with fixed limitations.
Please refer to int documentation for future reference.

Categorías

Más información sobre Logical en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by