How to plot a function for each element of an array N and with markers only?
Show older comments
As shown in the code below, this is only the important part of the code. I am trying to plot (umid1) versus ty for each element of N array, and only with markers. I would really appreciate your help.
N = [10,14,20,24,40];
dx = 1./N; % 1 is for the length of the wall.
for m = 1:length(N)
Ni = N(m);
mu = 0.1; %i.e. Re=10
nx = Ni+1;
ny = nx;
for b = 2:ny-1
umid(b) = (p(round(nx/2),b+1)-p(round(nx,2),b-1))/(2*h);
end
umid(ny) = 2*pi^2*(sin(pi*(round(nx/2)-1)*h)^2);
ty{m} = linspace (0, (ny-1)*h, ny)';
umid1{m} = umid;
plot (ty{m}, umid1{m})
end
%plot(ty,umid1, '-*', 'LineWidth', 2)
ylim([-2 1]);
xlabel('\delta x');
ylabel('force');
title("Force on the plate versus grid size");
Answers (1)
Bjorn Gustavsson
on 22 Mar 2022
If I understand you right something like this might be close enough. Change the line:
plot (ty{m}, umid1{m})
to
ph(m) = plot(ty{m}, umid1{m},'.','color',rand(1,3));
hold on
Then you have acxess to the handles of the different plots and can adjust the marker, its size and colour after the end of the script with set and get, and insert those commands into the script once you've tailored the plot to your liking.
HTH
Categories
Find more on Logical in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!