how to write summation

2 visualizaciones (últimos 30 días)
shiv gaur
shiv gaur el 21 de Feb. de 2022
Comentada: Walter Roberson el 24 de Feb. de 2022
pl write in this summation

Respuesta aceptada

Walter Roberson
Walter Roberson el 24 de Feb. de 2022
offset = 1; % Indices are 1-based in Matlab
S = 0;
for p = 0:i
S = S + A(offset+p) * C(offset + i - p);
end
  6 comentarios
Rik
Rik el 24 de Feb. de 2022
This is an honest question: why don't you format your code? I'm serious. Why do you only use one of these three buttons?
And why do you insist on leaving out any interpunction from your text? Can't you see that makes it harder to read?
Walter Roberson
Walter Roberson el 24 de Feb. de 2022
You are already asking for the solution to that power series in several questions. Concentrate on them, instead of asking here in comments on a completely different question.

Iniciar sesión para comentar.

Más respuestas (1)

Jan
Jan el 23 de Feb. de 2022
S = 0;
for p = 1:i+1 % Indices are 1-based in Matlab
S = S + A(p) + C(i - p);
end
  7 comentarios
shiv gaur
shiv gaur el 24 de Feb. de 2022
elabrate with example ans must be verify by taking any value
Rik
Rik el 24 de Feb. de 2022
Is your shift key broken? And the keys for the . , and ? symbols? That must be very difficult.
You didn't provide values for A, so apparently those don't matter. Why should Jan pick some numbers to show his code works? You could have done exactly like me: write the example below. Then you could actually show what your problem is. If you can't explain it in English, you should explain it in Matlab.
i=10;
A=rand(i+1,1);
C=rand(size(A));
S = 0;
for p = 1:i+1 % Indices are 1-based in Matlab
S = S + A(p) + C(i - p);
end
Array indices must be positive integers or logical values.
And now we can see that Jan made a small mistake: he corrected the indexing of A, but forgot to fix the indexing of C. Walter has now posted an answer that fixes this.
Also, sending me emails will not do anything. You should format your code as code. It isn't hard. Press ctrl-E before you paste any code or use the bar that appears when you write . Using interpunction will also help. If you post code that doesn't run when you click the small run icon, then the problem is not that I haven't seen your research, the problem is that you didn't include all variable definitions. I did not close your question because I was unable to answer your question, I closed it because you seem to be unwilling to use the tools provided to you. If I insisted on answering your questions in a Dutch dialect, you would not be able to understand me and my answer would be useless to you. If you insist on not formatting your posts and not using any interpunction you make your responses almost useless as well.

Iniciar sesión para comentar.

Categorías

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

Etiquetas

Productos


Versión

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by