How to save output?
1 次查看(过去 30 天)
显示 更早的评论
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?
0 个评论
采纳的回答
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’.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Loops and Conditional Statements 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!