I am running the following code and when the figures pop-up, they are blank without any lines.
I have tried running the Matlab in the software mode, thinking that the problem is in the OpenGL, but nothing changed.
So the error must be in the code , but I cannot figure out where. I appreacate any help on this, as I am stuck..
c1=3.74*10^8;
c2=1.44*10^4;
T1=30;
T2=90;
T3=120;
a1=0;
a2=0;
a3=0;
max1=0;
max2=0;
max3=0;
figure(1);
for a=0:0.01:300
M=c1/((a^5)*(exp(c2/(a*T1))-1));
plot(a,M,'b')
if M>max3
max3=M; a3=a;
end
hold on
end
figure(2);
for a=0:0.01:80
M=c1/((a^5)*(exp(c2/(a*T2))-1));
plot(a,M,'r')
if M>max2
max2=M; a2=a;
end
hold on
end
figure(3);
for a=0:0.01:80
M=c1/((a^5)*(exp(c2/(a*T3))-1));
plot(a,M,'g')
if M>max1
max1=M; a1=a;
end
hold on
end

 採用された回答

Image Analyst
Image Analyst 2020 年 1 月 19 日

0 投票

Try this:
clc
clear all
close all
c1 = 3.74*10^8;
c2 = 1.44*10^4;
T1 = 30;
T2 = 90;
T3 = 120;
a1 = 0;
a2 = 0;
a3 = 0;
max1 = 0;
max2 = 0;
max3 = 0;
subplot(1, 3, 1);
a = 0:0.01:300;
M = zeros(1, length(a));
fprintf('Starting loop #1 to compute %d values.\n', length(a));
for k = 1 : length(a)
M(k) = c1/((a(k)^5)*(exp(c2/(a(k)*T1))-1));
if M(k)>max3
max3 = M(k);
a3 = a;
end
hold on
end
plot(a, M, 'b-', 'LineWidth', 2)
grid on;
xlabel('a', 'FontSize', 15);
ylabel('M', 'FontSize', 15);
drawnow;
subplot(1, 3, 2);
a = 0:0.01:80;
M = zeros(1, length(a));
fprintf('Starting loop #2 to compute %d values.\n', length(a));
for k = 1 : length(a)
M(k) = c1/((a(k)^5)*(exp(c2/(a(k)*T2))-1));
if M(k) > max2
max2 = M(k);
a2 = a;
end
hold on
end
plot(a, M, 'r-', 'LineWidth', 2)
grid on;
xlabel('a', 'FontSize', 15);
ylabel('M', 'FontSize', 15);
drawnow;
subplot(1, 3, 3);
a = 0:0.01:80;
M = zeros(1, length(a));
fprintf('Starting loop #3 to compute %d values.\n', length(a));
for k = 1 : length(a)
M(k) = c1/((a(k)^5)*(exp(c2/(a(k)*T3))-1));
if M(k) > max1
max1 = M(k);
a1 = a;
end
hold on
end
darkGreen = [0, 0.5, 0];
plot(a, M, 'g', 'Color', darkGreen, 'LineWidth', 2)
grid on;
xlabel('a', 'FontSize', 15);
ylabel('M', 'FontSize', 15);
0000 Screenshot.png
Command window shows:
Starting loop #1 to compute 30001 values.
Starting loop #2 to compute 8001 values.
Starting loop #3 to compute 8001 values.

1 件のコメント

Ivaylo Ivanov
Ivaylo Ivanov 2020 年 1 月 20 日
Thank you for the code and your work. I would never though on it from this side.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeGraphics Performance についてさらに検索

製品

リリース

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by