i have two arrays in matlab code and i want to plot them by two lines on the same graph
Show older comments
i have two arrays in matlab code and i want to plot them by two lines on the same graph
Answers (1)
Soniya Jain
on 10 Jul 2021
plot(Array1);
hold on;
plot(Array2);
hold off;
hold will retain current plot when adding new plots.
4 Comments
Momen AlManaseh
on 10 Jul 2021
Soniya Jain
on 10 Jul 2021
Why are you plotting empty array?
You need to define the array 1st with some elements like,
A = [1 3 4];
then use A into the plot function,
plot(A);
or else you can directly pass the array into the function,
plot([1 3 4]);
To understand plot function in more detail, you can refer the MATLAB documentation of it. (https://in.mathworks.com/help/matlab/ref/plot.html)
Momen AlManaseh
on 10 Jul 2021
Soniya Jain
on 10 Jul 2021
Edited: Soniya Jain
on 10 Jul 2021
I guess you are trying to plot cell array as using {}, which is invalid argument in plot function, so you can first covert cell array to vector using
or
functions, and then try plotting.
Categories
Find more on 2-D and 3-D Plots 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!