# How to display only few values in a plot rather than for whole points in a big array?

20 vues (au cours des 30 derniers jours)
RITU SRIVASTAVA le 23 Sep 2022
Commenté : RITU SRIVASTAVA le 23 Sep 2022
i have to plot a graph for a variable T which is dependent on two variables x and t with x and T as x and y axes respectively at some specific values of t. I have written the following code for that:
y=0.01;
t=y:10*y:1000*y; % t=time (hr)
x=0:0.001:1;
for l=1:length(x)
for k=1:length(t)
a=60*sqrt(4*alpha*t(k));
b=a/sqrt(pi);
c=qs/K;
d=exp(-(x(l)/a).^2);
T(l,k)=c*(b*d-x(l).*erfc(x(l)/a))+Ti;
end
end
ts=t(:,4);
plot(x,T);
when I'm running it the graph is plotting for all the values of t in the array which makes the plot a solid like display. I have to plot for some 8 to 10 values of t only please help!!!!!!!!!
##### 0 commentairesAfficher -2 commentaires plus anciensMasquer -2 commentaires plus anciens

Connectez-vous pour commenter.

### Réponse acceptée

Karim le 23 Sep 2022
See below for a demonstration, i had to assume some parameters. However the plotting princaple remains the same.
% these parameters were missing from the OP's question, hence assumed to be 1
alpha = 1;
qs = 1;
K = 1;
Ti = 1;
% parameters from the OP's question
y = 0.01;
t = y:10*y:1000*y;
x = 0:0.001:1;
% initialize matrix T
T = zeros(length(x),length(t));
for l = 1:length(x)
for k = 1:length(t)
a = 60*sqrt(4*alpha*t(k));
b = a/sqrt(pi);
c = qs/K;
d = exp(-(x(l)./a).^2);
T(l,k) = c*(b*d-x(l).*erfc(x(l)./a))+Ti;
end
end
ts = t(:,4);
% make the full plot
figure
plot(x,T)
grid on
%% only plot some selected 't' values
% first pick a few t values
T_pick = [1 5 10 20 50 75 100];
% in the plot command, use the 2nd dimension to plot the selected values
figure
plot(x, T(:,T_pick))
grid on
##### 1 commentaireAfficher -1 commentaires plus anciensMasquer -1 commentaires plus anciens
RITU SRIVASTAVA le 23 Sep 2022
Thankyou sir, its working....

Connectez-vous pour commenter.

### Plus de réponses (1)

Davide Masiello le 23 Sep 2022
n = 10;
plot(x,T(:,1:n:end));
By increasing the value of n you decrease the number of lines shown in your plot.
##### 1 commentaireAfficher -1 commentaires plus anciensMasquer -1 commentaires plus anciens
RITU SRIVASTAVA le 23 Sep 2022
Thankyou sir, its working well.

Connectez-vous pour commenter.

### Catégories

En savoir plus sur 2-D and 3-D Plots dans Help Center et File Exchange

R2022a

### Community Treasure Hunt

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

Start Hunting!

Translated by