What does the >> n = 1:100; >> x = ( (-1).^(n+1) ) ./ (2*n - 1); >> y = sum(x) >>plot(x(1,1:4)) mean?
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
NN
el 8 de Oct. de 2023
Comentada: NN
el 8 de Oct. de 2023
>> n = 1:100;
>> x = ( (-1).^(n+1) ) ./ (2*n - 1);
>> y = sum(x)
>>plot(x(1,1:4))
While executing this, what is the meaning and answer of plot line (Last command)?
1 comentario
John D'Errico
el 8 de Oct. de 2023
Editada: John D'Errico
el 8 de Oct. de 2023
Why not try it?
Even better, why not take a basic MATLAB tutorial, and learn MATLAB? It will be time well spent. After all, is there a reason why we should be writing an entire tutorial in MATLAB for you here, when it already exists?
If not, then look at one line at a time. TRY IT! If you don't know what the first line does, then you definitely need to start reading the manual.
Respuesta aceptada
Image Analyst
el 8 de Oct. de 2023
x is a row vector so it doesn't need two indexes. y is assigned but not used. The plot() plots the first 4 values from the x array (row 1, columns 1-4):
n = 1:100;
x = ( (-1).^(n+1) ) ./ (2*n - 1)
y = sum(x)
plot(x(1, 1:4), 'b.-', 'LineWidth', 2, 'MarkerSize', 40)
grid on;
title('Plot of first 4 values of x in row 1')
ylabel('x');
xlabel('Index')
To learn other fundamental concepts, invest 2 hours of your time here:
Más respuestas (0)
Ver también
Categorías
Más información sobre Get Started with MATLAB 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!