Email: [email protected]

This Portal for internal use only!

  • My Download
  • Checkout
Application Package Repository Telkom University
All Categories

All Categories

  • Visual Paradigm
  • IBM
  • Adobe
  • Google
  • Matlab
  • Microsoft
    • Microsoft Apps
    • Analytics
    • AI + Machine Learning
    • Compute
    • Database
    • Developer Tools
    • Internet Of Things
    • Learning Services
    • Middleware System
    • Networking
    • Operating System
    • Productivity Tools
    • Security
    • VLS
      • Windows
      • Office
  • Opensource
  • Wordpress
    • Plugin WP
    • Themes WP
  • Others

Search

0 Wishlist

Cart

Categories
  • Microsoft
    • Microsoft Apps
    • Office
    • Operating System
    • VLS
    • Developer Tools
    • Productivity Tools
    • Database
    • AI + Machine Learning
    • Middleware System
    • Learning Services
    • Analytics
    • Networking
    • Compute
    • Security
    • Internet Of Things
  • Adobe
  • Matlab
  • Google
  • Visual Paradigm
  • WordPress
    • Plugin WP
    • Themes WP
  • Opensource
  • Others
More Categories Less Categories
  • Get Pack
    • Product Category
    • Simple Product
    • Grouped Product
    • Variable Product
    • External Product
  • My Account
    • Download
    • Cart
    • Checkout
    • Login
  • About Us
    • Contact
    • Forum
    • Frequently Questions
    • Privacy Policy
  • Forum
    • News
      • Category
      • News Tag

iconTicket Service Desk

  • My Download
  • Checkout
Application Package Repository Telkom University
All Categories

All Categories

  • Visual Paradigm
  • IBM
  • Adobe
  • Google
  • Matlab
  • Microsoft
    • Microsoft Apps
    • Analytics
    • AI + Machine Learning
    • Compute
    • Database
    • Developer Tools
    • Internet Of Things
    • Learning Services
    • Middleware System
    • Networking
    • Operating System
    • Productivity Tools
    • Security
    • VLS
      • Windows
      • Office
  • Opensource
  • Wordpress
    • Plugin WP
    • Themes WP
  • Others

Search

0 Wishlist

Cart

Menu
  • Home
    • Download Application Package Repository Telkom University
    • Application Package Repository Telkom University
    • Download Official License Telkom University
    • Download Installer Application Pack
    • Product Category
    • Simple Product
    • Grouped Product
    • Variable Product
    • External Product
  • All Pack
    • Microsoft
      • Operating System
      • Productivity Tools
      • Developer Tools
      • Database
      • AI + Machine Learning
      • Middleware System
      • Networking
      • Compute
      • Security
      • Analytics
      • Internet Of Things
      • Learning Services
    • Microsoft Apps
      • VLS
    • Adobe
    • Matlab
    • WordPress
      • Themes WP
      • Plugin WP
    • Google
    • Opensource
    • Others
  • My account
    • Download
    • Get Pack
    • Cart
    • Checkout
  • News
    • Category
    • News Tag
  • Forum
  • About Us
    • Privacy Policy
    • Frequently Questions
    • Contact
Home/Matlab/Plot not showing all results

Plot not showing all results

PuTI / 2025-03-12
Plot not showing all results
Matlab News

I need my graph to show the results from all lengths (i.e. all 5 coloured lines) but am only outputting 2 lines for one of the graphs. Both my code and the graphs are below. Please help.
clc; clear; close all;

%% Section 1: Development of Applied Thermal and Solute Concentration Fields
L_values = linspace(0.03, 0.25, 5); % Separation distance [m] (5 samples for clarity)
Nx = 200; % Number of spatial steps
Nt = 5000; % Number of time steps
dt = 0.005; % Time step size

% Thermal diffusivity values for aluminum alloy (m^2/s)
alpha_L = 3.26e-5; % Liquid phase
alpha_S = 6.58e-5; % Solid phase

% Solute diffusivity in liquid (m^2/s)
D_L = 1e-11;

% Interface velocity range
V = linspace(1.67e-5, 1.67e-4, 20); % Velocity range in m/s

% Partition coefficient & solute parameters
k = 0.85; % Partition coefficient
c0 = 7.26; % Initial solute concentration (wt% Al)
m = -3; % Liquidus slope (K/wt% Al)

[G_range, V_mesh] = meshgrid(linspace(1e4, 1e6, 20), V);
delta_c = sqrt(D_L ./ V_mesh); % Solute boundary layer thickness
G_critical = -2 * m * c0 ./ delta_c; % Constitutional gradient

%% Section 2: Initialize Figures
figure(1); hold on; % Temperature distribution plot
figure(2); hold on; % Solute concentration plot

%% Section 3: Loop Over Different L Values
for L = L_values
dx = L / Nx; % Spatial step size
x = linspace(0, L, Nx); % Position array
s = 0.02; % Initial interface position

% Initialize temperature profile
T = zeros(Nx, 1);
T(1:Nx/2) = linspace(1450, 1350, Nx/2); % Melt zone
T(Nx/2+1:end) = linspace(1150, 900, Nx/2); % Cold zone

%% Section 4: Applied Thermal Gradient (Finite Difference)
for t = 1:Nt
T_new = T;
for i = 2:Nx-1
if x(i) < s
T_new(i) = T(i) + alpha_S * dt / dx^2 * (T(i+1) – 2*T(i) + T(i-1));
else
T_new(i) = T(i) + alpha_L * dt / dx^2 * (T(i+1) – 2*T(i) + T(i-1));
end
end
T = T_new;
s = s + V(1) * dt; % Update interface position
end

%% Section 5: Plot Results for Each L
figure(1); % ensuring we’re plotting on the right figure
plot(x, T, ‘LineWidth’, 2, ‘DisplayName’, sprintf(‘L = %.2f m’, L));

figure(2);
plot(x, linspace(c0, c0 * k, Nx), ‘LineWidth’, 2, ‘DisplayName’, sprintf(‘L = %.2f m’, L));
end

%% Section 6: Finalize Temperature Plot
figure(1);
xlabel(‘Position (m)’); ylabel(‘Temperature (C)’);
title(‘Temperature Distribution for Different L Values’);
grid on; legend show; hold off;

%% Section 7: Finalize Solute Concentration Plot
figure(2);
xlabel(‘Position (m)’); ylabel(‘Solute Concentration (wt%)’);
title(‘Solute Concentration Distribution for Different L Values’);
grid on; legend show; hold off;I need my graph to show the results from all lengths (i.e. all 5 coloured lines) but am only outputting 2 lines for one of the graphs. Both my code and the graphs are below. Please help.
clc; clear; close all;

%% Section 1: Development of Applied Thermal and Solute Concentration Fields
L_values = linspace(0.03, 0.25, 5); % Separation distance [m] (5 samples for clarity)
Nx = 200; % Number of spatial steps
Nt = 5000; % Number of time steps
dt = 0.005; % Time step size

% Thermal diffusivity values for aluminum alloy (m^2/s)
alpha_L = 3.26e-5; % Liquid phase
alpha_S = 6.58e-5; % Solid phase

% Solute diffusivity in liquid (m^2/s)
D_L = 1e-11;

% Interface velocity range
V = linspace(1.67e-5, 1.67e-4, 20); % Velocity range in m/s

% Partition coefficient & solute parameters
k = 0.85; % Partition coefficient
c0 = 7.26; % Initial solute concentration (wt% Al)
m = -3; % Liquidus slope (K/wt% Al)

[G_range, V_mesh] = meshgrid(linspace(1e4, 1e6, 20), V);
delta_c = sqrt(D_L ./ V_mesh); % Solute boundary layer thickness
G_critical = -2 * m * c0 ./ delta_c; % Constitutional gradient

%% Section 2: Initialize Figures
figure(1); hold on; % Temperature distribution plot
figure(2); hold on; % Solute concentration plot

%% Section 3: Loop Over Different L Values
for L = L_values
dx = L / Nx; % Spatial step size
x = linspace(0, L, Nx); % Position array
s = 0.02; % Initial interface position

% Initialize temperature profile
T = zeros(Nx, 1);
T(1:Nx/2) = linspace(1450, 1350, Nx/2); % Melt zone
T(Nx/2+1:end) = linspace(1150, 900, Nx/2); % Cold zone

%% Section 4: Applied Thermal Gradient (Finite Difference)
for t = 1:Nt
T_new = T;
for i = 2:Nx-1
if x(i) < s
T_new(i) = T(i) + alpha_S * dt / dx^2 * (T(i+1) – 2*T(i) + T(i-1));
else
T_new(i) = T(i) + alpha_L * dt / dx^2 * (T(i+1) – 2*T(i) + T(i-1));
end
end
T = T_new;
s = s + V(1) * dt; % Update interface position
end

%% Section 5: Plot Results for Each L
figure(1); % ensuring we’re plotting on the right figure
plot(x, T, ‘LineWidth’, 2, ‘DisplayName’, sprintf(‘L = %.2f m’, L));

figure(2);
plot(x, linspace(c0, c0 * k, Nx), ‘LineWidth’, 2, ‘DisplayName’, sprintf(‘L = %.2f m’, L));
end

%% Section 6: Finalize Temperature Plot
figure(1);
xlabel(‘Position (m)’); ylabel(‘Temperature (C)’);
title(‘Temperature Distribution for Different L Values’);
grid on; legend show; hold off;

%% Section 7: Finalize Solute Concentration Plot
figure(2);
xlabel(‘Position (m)’); ylabel(‘Solute Concentration (wt%)’);
title(‘Solute Concentration Distribution for Different L Values’);
grid on; legend show; hold off; I need my graph to show the results from all lengths (i.e. all 5 coloured lines) but am only outputting 2 lines for one of the graphs. Both my code and the graphs are below. Please help.
clc; clear; close all;

%% Section 1: Development of Applied Thermal and Solute Concentration Fields
L_values = linspace(0.03, 0.25, 5); % Separation distance [m] (5 samples for clarity)
Nx = 200; % Number of spatial steps
Nt = 5000; % Number of time steps
dt = 0.005; % Time step size

% Thermal diffusivity values for aluminum alloy (m^2/s)
alpha_L = 3.26e-5; % Liquid phase
alpha_S = 6.58e-5; % Solid phase

% Solute diffusivity in liquid (m^2/s)
D_L = 1e-11;

% Interface velocity range
V = linspace(1.67e-5, 1.67e-4, 20); % Velocity range in m/s

% Partition coefficient & solute parameters
k = 0.85; % Partition coefficient
c0 = 7.26; % Initial solute concentration (wt% Al)
m = -3; % Liquidus slope (K/wt% Al)

[G_range, V_mesh] = meshgrid(linspace(1e4, 1e6, 20), V);
delta_c = sqrt(D_L ./ V_mesh); % Solute boundary layer thickness
G_critical = -2 * m * c0 ./ delta_c; % Constitutional gradient

%% Section 2: Initialize Figures
figure(1); hold on; % Temperature distribution plot
figure(2); hold on; % Solute concentration plot

%% Section 3: Loop Over Different L Values
for L = L_values
dx = L / Nx; % Spatial step size
x = linspace(0, L, Nx); % Position array
s = 0.02; % Initial interface position

% Initialize temperature profile
T = zeros(Nx, 1);
T(1:Nx/2) = linspace(1450, 1350, Nx/2); % Melt zone
T(Nx/2+1:end) = linspace(1150, 900, Nx/2); % Cold zone

%% Section 4: Applied Thermal Gradient (Finite Difference)
for t = 1:Nt
T_new = T;
for i = 2:Nx-1
if x(i) < s
T_new(i) = T(i) + alpha_S * dt / dx^2 * (T(i+1) – 2*T(i) + T(i-1));
else
T_new(i) = T(i) + alpha_L * dt / dx^2 * (T(i+1) – 2*T(i) + T(i-1));
end
end
T = T_new;
s = s + V(1) * dt; % Update interface position
end

%% Section 5: Plot Results for Each L
figure(1); % ensuring we’re plotting on the right figure
plot(x, T, ‘LineWidth’, 2, ‘DisplayName’, sprintf(‘L = %.2f m’, L));

figure(2);
plot(x, linspace(c0, c0 * k, Nx), ‘LineWidth’, 2, ‘DisplayName’, sprintf(‘L = %.2f m’, L));
end

%% Section 6: Finalize Temperature Plot
figure(1);
xlabel(‘Position (m)’); ylabel(‘Temperature (C)’);
title(‘Temperature Distribution for Different L Values’);
grid on; legend show; hold off;

%% Section 7: Finalize Solute Concentration Plot
figure(2);
xlabel(‘Position (m)’); ylabel(‘Solute Concentration (wt%)’);
title(‘Solute Concentration Distribution for Different L Values’);
grid on; legend show; hold off; graphs MATLAB Answers — New Questions

​

Tags: matlab

Share this!

Related posts

Generate ST code from a look-up table with CONSTANT attribute
2025-05-22

Generate ST code from a look-up table with CONSTANT attribute

“no healthy upstream” error when trying to access My Account
2025-05-22

“no healthy upstream” error when trying to access My Account

MATLAB Answers is provisionally back?
2025-05-21

MATLAB Answers is provisionally back?

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Search

Categories

  • Matlab
  • Microsoft
  • News
  • Other
Application Package Repository Telkom University

Tags

matlab microsoft opensources
Application Package Download License

Application Package Download License

Adobe
Google for Education
IBM
Matlab
Microsoft
Wordpress
Visual Paradigm
Opensource

Sign Up For Newsletters

Be the First to Know. Sign up for newsletter today

Application Package Repository Telkom University

Portal Application Package Repository Telkom University, for internal use only, empower civitas academica in study and research.

Information

  • Telkom University
  • About Us
  • Contact
  • Forum Discussion
  • FAQ
  • Helpdesk Ticket

Contact Us

  • Ask: Any question please read FAQ
  • Mail: [email protected]
  • Call: +62 823-1994-9941
  • WA: +62 823-1994-9943
  • Site: Gedung Panambulai. Jl. Telekomunikasi

Copyright © Telkom University. All Rights Reserved. ch

  • FAQ
  • Privacy Policy
  • Term

This Application Package for internal Telkom University only (students and employee). Chiers... Dismiss