How to save output?

1 次查看(过去 30 天)
Ammy
Ammy 2021-3-25
x=[0:n-1];
y=[0:n-1];
figure
for i=1:5
for j=1:5
if rem(((y(j))^2)-((x(i))^3)-2*(x(i))-3,5)==0
plot(x(i),y(j),'r o');
hold on;
end
end
end
grid;
hold off;
How can I save output of loop ? For example in this case I have 6 points (1, 1),(1, 4),(2, 0),(3, 1),(3, 4),(4, 0), how can I save it?

采纳的回答

Star Strider
Star Strider 2021-3-25
Try this:
n = 10;
x=[0:n-1];
y=[0:n-1];
k = 0; % <- ADD
figure
for i=1:5
for j=1:5
if rem(((y(j))^2)-((x(i))^3)-2*(x(i))-3,5)==0
k = k+1; % <- ADD
xy_mtx(k,:) = [x(i) y(j)]; % <- ADD
plot(x(i),y(j),'r o');
hold on;
end
end
end
grid;
hold off
The results are saved in ‘xy_mtx’.
  2 个评论
Ammy
Ammy 2021-3-25
Thank you very much
Its work
Star Strider
Star Strider 2021-3-25
As always, my pleasure!

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Loops and Conditional Statements 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by