Matlab doesn't like my function, why?

3 vues (au cours des 30 derniers jours)
AB29
AB29 le 2 Jan 2024
Commenté : AB29 le 3 Jan 2024
Does anyone know what i am doing wrong here. i am trying to plot my amplitudes of my fourier series from 0-15 my bn is only a number when odd which explains my matrix.

Réponse acceptée

Torsten
Torsten le 2 Jan 2024
Déplacé(e) : Torsten le 2 Jan 2024
Use elementwise division (./) and multiplication (.*) in the computation of An and B:

Plus de réponses (1)

Dyuman Joshi
Dyuman Joshi le 2 Jan 2024
Modifié(e) : Dyuman Joshi le 2 Jan 2024
The element-wise operators to be used here are ./ and .* (There is .^ in addition), see - Array vs Matrix Operations
Also, while defining the variable C - the letters a, b of An, Bn are supposed to be uppercase, and, n of plot C vs N should be lowercase. MATLAB is case sensitive.
And the syntax of calling plot() is incorrect. Take a look at the documentation page to learn the acceptable syntaxes of the function plot() here - https://in.mathworks.com/help/matlab/ref/plot.html
If you are new to MATLAB, I suggest you take the free MATLAB Onramp tutorial to learn the fundamentals/basics of MATLAB along with the notation/syntax.
  9 commentaires
Dyuman Joshi
Dyuman Joshi le 3 Jan 2024
@AB29, the signs should be positive, as squaring a negative value results in a positive value.
AB29
AB29 le 3 Jan 2024
Thanks all.

Connectez-vous pour commenter.

Produits


Version

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by