How to mark different plots within the same loop?

조회 수: 19 (최근 30일)
Petar Markic
Petar Markic 2021년 7월 4일
댓글: Petar Markic 2021년 7월 4일
Hi guys,
i would like to know how to mark these 5 different results i get from this function with different markers like 'o','+','*','x','.'. , right now they are only differentiated by colour but i want to put these markers in so it would be easily visible even when printed in black,can anyone give any advice?
It would be much appreciated!
M=0:0.2:4;
Ta=1;
for i=220:20:300
T=((1+((1.4-1)/2)*0.85.*M.^2)*(Ta*i));
plot(M,T);
ylim([250,700])
hold on;
grid on;
end
xlabel('Machov broj - {\it Ma}')
ylabel('Temperatura oplate - {\it T} (K)')
legend('T_o=220 K','T_o=240 K','T_o=260 K','T_o=280 K','T_o=300 K','location','best')
hold off

채택된 답변

Image Analyst
Image Analyst 2021년 7월 4일
Try this:
clc; % Clear the command window.
close all; % Close all figures (except those of imtool.)
clear; % Erase all existing variables. Or clearvars if you want.
workspace; % Make sure the workspace panel is showing.
format long g;
format compact;
fontSize = 15;
M=0:0.2:4;
Ta=1;
values = 220 : 20 : 300;
numCurves = length(values)
plotColors = jet(length(values));
lineStyles = {'-.', '-x', '-s', '-+', '-o'};
for k = 1 : numCurves
thisValue = values(k);
T = ((1 + ((1.4 - 1) / 2) * 0.85 .* M .^ 2) * (Ta * thisValue));
thisColor = plotColors(k, :);
thisStyle = lineStyles{k};
plot(M, T, thisStyle, 'Color', thisColor, 'LineWidth', 2, 'MarkerSize', 25);
ylim([250,700])
hold on;
grid on;
end
xlabel('Machov broj - {\it Ma}', 'FontSize', fontSize)
ylabel('Temperatura oplate - {\it T} (K)', 'FontSize', fontSize)
legend('T_o=220 K','T_o=240 K','T_o=260 K','T_o=280 K','T_o=300 K','location','best')
hold off
g = gcf;
g.WindowState = 'maximized'
  댓글 수: 1
Petar Markic
Petar Markic 2021년 7월 4일
I've done some minor corrections to suit my needs but your idea is what i was looking for, thanks and have a good day!

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Yongjian Feng
Yongjian Feng 2021년 7월 4일
https://www.mathworks.com/help/matlab/creating_plots/create-line-plot-with-markers.html
  댓글 수: 1
Petar Markic
Petar Markic 2021년 7월 4일
Thank you for your time, but this doesn't help. I know how to do it on one plot but how to do it that different results in the same loop have differnet markers?

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Creating, Deleting, and Querying Graphics Objects에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by