Tag Archives: matlab
Error using fmincon function
% Define constants for Antoine’s equation
A = 8.07131;
B = 1730.63;
C = 233.426;
% Define the operating temperature at the outlet of the evaporator (in Celsius)
T = 70; % You can adjust this value based on the actual temperature
% Define the partial pressure of water at the outlet of the evaporator (kPa)
Pi = 30;
% Define the mass flow rate of seawater entering the evaporator (in kg/s)
Fseawater = 0.020; % kg/s
% Define the objective function to maximize water recovery
objective = @(x_vap) -calculate_water_recovery(x_vap, A, B, C, T, Pi, Fseawater);
% Define lower and upper bounds for the decision variable (mole fraction of water in vapor phase)
lb = 0; % Lower bound
ub = 1; % Upper bound
constraint = @(x) 20 – calculate_water_recovery(x, A, B, C, T, Pi, Fseawater);
% Perform optimization
options = optimoptions(‘fmincon’, ‘Display’, ‘iter’);
[x_vap_opt, ~, exitflag] = fmincon(objective, 0.5, [], [], [], [], lb, ub, [], [], options);
if exitflag > 0
% Calculate water recovery and display results
[Lwater, Vwater] = calculate_water_recovery(x_vap_opt, A, B, C, T, Pi, Fseawater);
disp([‘Optimal mole fraction of water in vapor phase: ‘, num2str(x_vap_opt)]);
disp([‘Optimal mass flow rate of freshwater product: ‘, num2str(Vwater), ‘ kg/s’]);
disp([‘Optimal percent water recovered: ‘, num2str(Lwater), ‘%’]);
else
disp(‘Optimization failed to converge.’);
end
function [Lwater, Vwater] = calculate_water_recovery(xi_vap, A, B, C, T, Pi, Fseawater)
% Calculate the saturation vapor pressure using Antoine’s equation
Pisat = exp(A – B / (C + T));
% Calculate the mole fraction of water in the liquid phase using Raoult’s law
xi_liq = Pi / Pisat;
% Calculate the mole fraction of water in the vapor phase
xi_vap = 1 – xi_liq;
% Calculate the mass flow rate of freshwater product
Vwater = xi_vap * (0.0180153); % kg/s
% Calculate the percent water recovered
Lwater = (1 – (Fseawater – Vwater) / Fseawater) * 100;
end% Define constants for Antoine’s equation
A = 8.07131;
B = 1730.63;
C = 233.426;
% Define the operating temperature at the outlet of the evaporator (in Celsius)
T = 70; % You can adjust this value based on the actual temperature
% Define the partial pressure of water at the outlet of the evaporator (kPa)
Pi = 30;
% Define the mass flow rate of seawater entering the evaporator (in kg/s)
Fseawater = 0.020; % kg/s
% Define the objective function to maximize water recovery
objective = @(x_vap) -calculate_water_recovery(x_vap, A, B, C, T, Pi, Fseawater);
% Define lower and upper bounds for the decision variable (mole fraction of water in vapor phase)
lb = 0; % Lower bound
ub = 1; % Upper bound
constraint = @(x) 20 – calculate_water_recovery(x, A, B, C, T, Pi, Fseawater);
% Perform optimization
options = optimoptions(‘fmincon’, ‘Display’, ‘iter’);
[x_vap_opt, ~, exitflag] = fmincon(objective, 0.5, [], [], [], [], lb, ub, [], [], options);
if exitflag > 0
% Calculate water recovery and display results
[Lwater, Vwater] = calculate_water_recovery(x_vap_opt, A, B, C, T, Pi, Fseawater);
disp([‘Optimal mole fraction of water in vapor phase: ‘, num2str(x_vap_opt)]);
disp([‘Optimal mass flow rate of freshwater product: ‘, num2str(Vwater), ‘ kg/s’]);
disp([‘Optimal percent water recovered: ‘, num2str(Lwater), ‘%’]);
else
disp(‘Optimization failed to converge.’);
end
function [Lwater, Vwater] = calculate_water_recovery(xi_vap, A, B, C, T, Pi, Fseawater)
% Calculate the saturation vapor pressure using Antoine’s equation
Pisat = exp(A – B / (C + T));
% Calculate the mole fraction of water in the liquid phase using Raoult’s law
xi_liq = Pi / Pisat;
% Calculate the mole fraction of water in the vapor phase
xi_vap = 1 – xi_liq;
% Calculate the mass flow rate of freshwater product
Vwater = xi_vap * (0.0180153); % kg/s
% Calculate the percent water recovered
Lwater = (1 – (Fseawater – Vwater) / Fseawater) * 100;
end % Define constants for Antoine’s equation
A = 8.07131;
B = 1730.63;
C = 233.426;
% Define the operating temperature at the outlet of the evaporator (in Celsius)
T = 70; % You can adjust this value based on the actual temperature
% Define the partial pressure of water at the outlet of the evaporator (kPa)
Pi = 30;
% Define the mass flow rate of seawater entering the evaporator (in kg/s)
Fseawater = 0.020; % kg/s
% Define the objective function to maximize water recovery
objective = @(x_vap) -calculate_water_recovery(x_vap, A, B, C, T, Pi, Fseawater);
% Define lower and upper bounds for the decision variable (mole fraction of water in vapor phase)
lb = 0; % Lower bound
ub = 1; % Upper bound
constraint = @(x) 20 – calculate_water_recovery(x, A, B, C, T, Pi, Fseawater);
% Perform optimization
options = optimoptions(‘fmincon’, ‘Display’, ‘iter’);
[x_vap_opt, ~, exitflag] = fmincon(objective, 0.5, [], [], [], [], lb, ub, [], [], options);
if exitflag > 0
% Calculate water recovery and display results
[Lwater, Vwater] = calculate_water_recovery(x_vap_opt, A, B, C, T, Pi, Fseawater);
disp([‘Optimal mole fraction of water in vapor phase: ‘, num2str(x_vap_opt)]);
disp([‘Optimal mass flow rate of freshwater product: ‘, num2str(Vwater), ‘ kg/s’]);
disp([‘Optimal percent water recovered: ‘, num2str(Lwater), ‘%’]);
else
disp(‘Optimization failed to converge.’);
end
function [Lwater, Vwater] = calculate_water_recovery(xi_vap, A, B, C, T, Pi, Fseawater)
% Calculate the saturation vapor pressure using Antoine’s equation
Pisat = exp(A – B / (C + T));
% Calculate the mole fraction of water in the liquid phase using Raoult’s law
xi_liq = Pi / Pisat;
% Calculate the mole fraction of water in the vapor phase
xi_vap = 1 – xi_liq;
% Calculate the mass flow rate of freshwater product
Vwater = xi_vap * (0.0180153); % kg/s
% Calculate the percent water recovered
Lwater = (1 – (Fseawater – Vwater) / Fseawater) * 100;
end fmincon, constraints MATLAB Answers — New Questions
All Widget Gauges are blank
Was just checking in on our ThingSpeak channels and all our Public Widgets are blank.
Don’t know when this started.
Anyone else seeing this?Was just checking in on our ThingSpeak channels and all our Public Widgets are blank.
Don’t know when this started.
Anyone else seeing this? Was just checking in on our ThingSpeak channels and all our Public Widgets are blank.
Don’t know when this started.
Anyone else seeing this? thingspeak MATLAB Answers — New Questions
Cannot refresh variables when exporting Simulink to FMU file
I am trying to create a simple FMU file from a SimuLink model. I made this many times before. Now, suddenly, I am getting the following error when I try to refresh the settings (using R2024a):
Unable to resolve the name ‘internal.getWSLDockerSettings’
I have no idea what that means. A reseach on google resulted in nothing.
I thank for any help.I am trying to create a simple FMU file from a SimuLink model. I made this many times before. Now, suddenly, I am getting the following error when I try to refresh the settings (using R2024a):
Unable to resolve the name ‘internal.getWSLDockerSettings’
I have no idea what that means. A reseach on google resulted in nothing.
I thank for any help. I am trying to create a simple FMU file from a SimuLink model. I made this many times before. Now, suddenly, I am getting the following error when I try to refresh the settings (using R2024a):
Unable to resolve the name ‘internal.getWSLDockerSettings’
I have no idea what that means. A reseach on google resulted in nothing.
I thank for any help. fmu, simulink MATLAB Answers — New Questions
INDEX EXCEEDS THE NUMBER OF ARRAY ELEMENTS.
% Load the signal data from the text file using the load command with the -ascii option
x = load(‘Lab7data1.txt’, ‘-ascii’);
% Plot the signal
%figure;
%plot(x);
%xlabel(‘Sample’);
%ylabel(‘Amplitude’);
%title(‘Original Signal’);
%grid on;
% Calculate the length of the signal in samples
signal_length = length(x);
num_periods = 100;
% Estimate the number of samples per period
samples_per_period = signal_length / num_periods;
% Check Nyquist condition
if samples_per_period >= 2
disp(‘Nyquist sampling rate is satisfied.’);
else
disp(‘Nyquist sampling rate is not satisfied.’);
end
% Calculate the current sampling rate
current_sampling_rate = 1 / samples_per_period;
% Estimate the down-sampling factor needed to reduce the sampling rate to
% the Nyquist
downsampling_factor = ceil(current_sampling_rate / 2);
% Down-sample the signal
downsampled_signal = x(1:downsampling_factor:end);
% Define the x-values for the down-sampled signal
downsampled_indices = 1:downsampling_factor:signal_length;
% Make sure the lengths match
if length(downsampled_indices) ~= length(downsampled_signal)
downsampled_indices = downsampled_indices(1:length(downsampled_signal));
end
% Interpolate the down-sampled signal to up-sample it
up_sampled_signal = interp1(downsampled_indices, downsampled_signal, 1:signal_length,’linear’);
% Plot both the original and down-sampled signals
figure;
plot(1:signal_length, x, ‘b’, ‘DisplayName’, ‘Original Signal’);
hold on;
plot(downsampled_signal, ‘ro’, ‘DisplayName’, ‘Down-sampled Signal’);
plot(up_sampled_signal, ‘g’, ‘DisplayName’, ‘Up-sampled Signal (Linear Interpolation)’);
hold off;
xlabel(‘Sample’);
ylabel(‘Amplitude’);
title(‘Original vs Down-sampled Signal vs Up-sampled Signal’);
legend(‘Location’, ‘best’);
grid on;% Load the signal data from the text file using the load command with the -ascii option
x = load(‘Lab7data1.txt’, ‘-ascii’);
% Plot the signal
%figure;
%plot(x);
%xlabel(‘Sample’);
%ylabel(‘Amplitude’);
%title(‘Original Signal’);
%grid on;
% Calculate the length of the signal in samples
signal_length = length(x);
num_periods = 100;
% Estimate the number of samples per period
samples_per_period = signal_length / num_periods;
% Check Nyquist condition
if samples_per_period >= 2
disp(‘Nyquist sampling rate is satisfied.’);
else
disp(‘Nyquist sampling rate is not satisfied.’);
end
% Calculate the current sampling rate
current_sampling_rate = 1 / samples_per_period;
% Estimate the down-sampling factor needed to reduce the sampling rate to
% the Nyquist
downsampling_factor = ceil(current_sampling_rate / 2);
% Down-sample the signal
downsampled_signal = x(1:downsampling_factor:end);
% Define the x-values for the down-sampled signal
downsampled_indices = 1:downsampling_factor:signal_length;
% Make sure the lengths match
if length(downsampled_indices) ~= length(downsampled_signal)
downsampled_indices = downsampled_indices(1:length(downsampled_signal));
end
% Interpolate the down-sampled signal to up-sample it
up_sampled_signal = interp1(downsampled_indices, downsampled_signal, 1:signal_length,’linear’);
% Plot both the original and down-sampled signals
figure;
plot(1:signal_length, x, ‘b’, ‘DisplayName’, ‘Original Signal’);
hold on;
plot(downsampled_signal, ‘ro’, ‘DisplayName’, ‘Down-sampled Signal’);
plot(up_sampled_signal, ‘g’, ‘DisplayName’, ‘Up-sampled Signal (Linear Interpolation)’);
hold off;
xlabel(‘Sample’);
ylabel(‘Amplitude’);
title(‘Original vs Down-sampled Signal vs Up-sampled Signal’);
legend(‘Location’, ‘best’);
grid on; % Load the signal data from the text file using the load command with the -ascii option
x = load(‘Lab7data1.txt’, ‘-ascii’);
% Plot the signal
%figure;
%plot(x);
%xlabel(‘Sample’);
%ylabel(‘Amplitude’);
%title(‘Original Signal’);
%grid on;
% Calculate the length of the signal in samples
signal_length = length(x);
num_periods = 100;
% Estimate the number of samples per period
samples_per_period = signal_length / num_periods;
% Check Nyquist condition
if samples_per_period >= 2
disp(‘Nyquist sampling rate is satisfied.’);
else
disp(‘Nyquist sampling rate is not satisfied.’);
end
% Calculate the current sampling rate
current_sampling_rate = 1 / samples_per_period;
% Estimate the down-sampling factor needed to reduce the sampling rate to
% the Nyquist
downsampling_factor = ceil(current_sampling_rate / 2);
% Down-sample the signal
downsampled_signal = x(1:downsampling_factor:end);
% Define the x-values for the down-sampled signal
downsampled_indices = 1:downsampling_factor:signal_length;
% Make sure the lengths match
if length(downsampled_indices) ~= length(downsampled_signal)
downsampled_indices = downsampled_indices(1:length(downsampled_signal));
end
% Interpolate the down-sampled signal to up-sample it
up_sampled_signal = interp1(downsampled_indices, downsampled_signal, 1:signal_length,’linear’);
% Plot both the original and down-sampled signals
figure;
plot(1:signal_length, x, ‘b’, ‘DisplayName’, ‘Original Signal’);
hold on;
plot(downsampled_signal, ‘ro’, ‘DisplayName’, ‘Down-sampled Signal’);
plot(up_sampled_signal, ‘g’, ‘DisplayName’, ‘Up-sampled Signal (Linear Interpolation)’);
hold off;
xlabel(‘Sample’);
ylabel(‘Amplitude’);
title(‘Original vs Down-sampled Signal vs Up-sampled Signal’);
legend(‘Location’, ‘best’);
grid on; array element MATLAB Answers — New Questions
Index exceeds matrix dimensions.
clc;
clear;
%Исходные данные
F=100; %частота следования импульсов, Гц
alpha=0.5; %Коэффициент скругления
U0=1; % Амплитуда несущего колебания, В
f0=100000; %частота несущего колебания, Гц
Fs=10*f0; %частота дискретизации, Гц
T=1/F; %Период следования импульсов, с
Ts=1/Fs; %Период дискретизации, с
f=140:0.1:160; % массив частот
M=length(f);
j=complex(0, 1);
%Добавление шума
SNR=-15; % добавление шума, дБ
% 1. Расчёт импульса приподнятого косинуса
delay=3; %задержка
g=rcosine(F, 200*F, ‘sqrt’, alpha, delay); %импульс приподнятого косинуса
g=g/max(g);
N1=length(g);
t1=0:(1/(200*F)):(N1-1)*(1/(200*F));
% 2. Синтез случайного кода
Nsym=100; %число символов
p=ceil(2.*rand(1,Nsym));
p=p-1;
%———————————-Модуляция DQPSK————
% 3. Расчёт символов a
a=zeros(1, Nsym);
for n=1:Nsym %Вычисление A и B
if p(n)==0
a(n)=-1;
end
if p(n)==1
a(n)=1;
end
end
n=1:Nsym;
figure(1)
stem(n, a);
%xlim([0, 20]);
ylim([-2, 2]);
xlabel(‘n’);
ylabel(‘a’);
grid on
% 4. Синтез модулирующего сигнала
N=Nsym*N1;
t=0:Ts:(N-1)*Ts;
Sa=zeros(1,N);
for n=1:Nsym
for k=1:N1
Sa(k+(n-1)*200*F)=a(n).*g(k)+Sa(k+(n-1)*200*F);
end
end
figure(2)
plot(t, Sa);
title(‘График модулирующего сигнала символов a’);
xlim([0, 10]);
ylim([-2, 2]);
xlabel(‘t, с’);
ylabel(‘Sa(t), В’);
grid on
% 5. Балансная модуляция
Ug=U0*cos(2*pi*f0*t); %несущее колебание
Uw=Sa.*Ug; %радиосигнал
P=mean(Uw.*Uw); % мощность в Вт
PF=10*log10((max(Uw.*Uw))/P); %пик-фактор
Ps=10*log10(P); % мощность в дБ
Noise=wgn(1, N, Ps-SNR);
Uw=Uw+Noise; % добавление шума
figure(3)
plot(t, Uw);
xlim([0, 20]);
ylim([-2, 2]);
xlabel(‘t, с’);
ylabel(‘Uw(t), В’);
grid on
%———————————-Демодуляция BPSK————
% 6. Балансная демодуляция
t=0:Ts:(N-1)*Ts;
Uda=Uw.*cos(2*pi*f0*t);
Sfa=filter(g, 1, Uda);
Sfa=Sfa/max(Sfa)*max(Sa);
t=0:(1/(200*F)):(N-1)*(1/(200*F));
figure(4)
subplot(2, 1, 1);
plot(t, Sfa);
title(‘График демодулированного сигнала a’);
xlim([0, 0.23]);
ylim([-2, 2]);
xlabel(‘t, с’);
ylabel(‘Sa(t), В’);
grid onclc;
clear;
%Исходные данные
F=100; %частота следования импульсов, Гц
alpha=0.5; %Коэффициент скругления
U0=1; % Амплитуда несущего колебания, В
f0=100000; %частота несущего колебания, Гц
Fs=10*f0; %частота дискретизации, Гц
T=1/F; %Период следования импульсов, с
Ts=1/Fs; %Период дискретизации, с
f=140:0.1:160; % массив частот
M=length(f);
j=complex(0, 1);
%Добавление шума
SNR=-15; % добавление шума, дБ
% 1. Расчёт импульса приподнятого косинуса
delay=3; %задержка
g=rcosine(F, 200*F, ‘sqrt’, alpha, delay); %импульс приподнятого косинуса
g=g/max(g);
N1=length(g);
t1=0:(1/(200*F)):(N1-1)*(1/(200*F));
% 2. Синтез случайного кода
Nsym=100; %число символов
p=ceil(2.*rand(1,Nsym));
p=p-1;
%———————————-Модуляция DQPSK————
% 3. Расчёт символов a
a=zeros(1, Nsym);
for n=1:Nsym %Вычисление A и B
if p(n)==0
a(n)=-1;
end
if p(n)==1
a(n)=1;
end
end
n=1:Nsym;
figure(1)
stem(n, a);
%xlim([0, 20]);
ylim([-2, 2]);
xlabel(‘n’);
ylabel(‘a’);
grid on
% 4. Синтез модулирующего сигнала
N=Nsym*N1;
t=0:Ts:(N-1)*Ts;
Sa=zeros(1,N);
for n=1:Nsym
for k=1:N1
Sa(k+(n-1)*200*F)=a(n).*g(k)+Sa(k+(n-1)*200*F);
end
end
figure(2)
plot(t, Sa);
title(‘График модулирующего сигнала символов a’);
xlim([0, 10]);
ylim([-2, 2]);
xlabel(‘t, с’);
ylabel(‘Sa(t), В’);
grid on
% 5. Балансная модуляция
Ug=U0*cos(2*pi*f0*t); %несущее колебание
Uw=Sa.*Ug; %радиосигнал
P=mean(Uw.*Uw); % мощность в Вт
PF=10*log10((max(Uw.*Uw))/P); %пик-фактор
Ps=10*log10(P); % мощность в дБ
Noise=wgn(1, N, Ps-SNR);
Uw=Uw+Noise; % добавление шума
figure(3)
plot(t, Uw);
xlim([0, 20]);
ylim([-2, 2]);
xlabel(‘t, с’);
ylabel(‘Uw(t), В’);
grid on
%———————————-Демодуляция BPSK————
% 6. Балансная демодуляция
t=0:Ts:(N-1)*Ts;
Uda=Uw.*cos(2*pi*f0*t);
Sfa=filter(g, 1, Uda);
Sfa=Sfa/max(Sfa)*max(Sa);
t=0:(1/(200*F)):(N-1)*(1/(200*F));
figure(4)
subplot(2, 1, 1);
plot(t, Sfa);
title(‘График демодулированного сигнала a’);
xlim([0, 0.23]);
ylim([-2, 2]);
xlabel(‘t, с’);
ylabel(‘Sa(t), В’);
grid on clc;
clear;
%Исходные данные
F=100; %частота следования импульсов, Гц
alpha=0.5; %Коэффициент скругления
U0=1; % Амплитуда несущего колебания, В
f0=100000; %частота несущего колебания, Гц
Fs=10*f0; %частота дискретизации, Гц
T=1/F; %Период следования импульсов, с
Ts=1/Fs; %Период дискретизации, с
f=140:0.1:160; % массив частот
M=length(f);
j=complex(0, 1);
%Добавление шума
SNR=-15; % добавление шума, дБ
% 1. Расчёт импульса приподнятого косинуса
delay=3; %задержка
g=rcosine(F, 200*F, ‘sqrt’, alpha, delay); %импульс приподнятого косинуса
g=g/max(g);
N1=length(g);
t1=0:(1/(200*F)):(N1-1)*(1/(200*F));
% 2. Синтез случайного кода
Nsym=100; %число символов
p=ceil(2.*rand(1,Nsym));
p=p-1;
%———————————-Модуляция DQPSK————
% 3. Расчёт символов a
a=zeros(1, Nsym);
for n=1:Nsym %Вычисление A и B
if p(n)==0
a(n)=-1;
end
if p(n)==1
a(n)=1;
end
end
n=1:Nsym;
figure(1)
stem(n, a);
%xlim([0, 20]);
ylim([-2, 2]);
xlabel(‘n’);
ylabel(‘a’);
grid on
% 4. Синтез модулирующего сигнала
N=Nsym*N1;
t=0:Ts:(N-1)*Ts;
Sa=zeros(1,N);
for n=1:Nsym
for k=1:N1
Sa(k+(n-1)*200*F)=a(n).*g(k)+Sa(k+(n-1)*200*F);
end
end
figure(2)
plot(t, Sa);
title(‘График модулирующего сигнала символов a’);
xlim([0, 10]);
ylim([-2, 2]);
xlabel(‘t, с’);
ylabel(‘Sa(t), В’);
grid on
% 5. Балансная модуляция
Ug=U0*cos(2*pi*f0*t); %несущее колебание
Uw=Sa.*Ug; %радиосигнал
P=mean(Uw.*Uw); % мощность в Вт
PF=10*log10((max(Uw.*Uw))/P); %пик-фактор
Ps=10*log10(P); % мощность в дБ
Noise=wgn(1, N, Ps-SNR);
Uw=Uw+Noise; % добавление шума
figure(3)
plot(t, Uw);
xlim([0, 20]);
ylim([-2, 2]);
xlabel(‘t, с’);
ylabel(‘Uw(t), В’);
grid on
%———————————-Демодуляция BPSK————
% 6. Балансная демодуляция
t=0:Ts:(N-1)*Ts;
Uda=Uw.*cos(2*pi*f0*t);
Sfa=filter(g, 1, Uda);
Sfa=Sfa/max(Sfa)*max(Sa);
t=0:(1/(200*F)):(N-1)*(1/(200*F));
figure(4)
subplot(2, 1, 1);
plot(t, Sfa);
title(‘График демодулированного сигнала a’);
xlim([0, 0.23]);
ylim([-2, 2]);
xlabel(‘t, с’);
ylabel(‘Sa(t), В’);
grid on matlab MATLAB Answers — New Questions
phase diagram of 3D Anderson model
L = 10; % system size
nr = 10;
nsteps = 100;
W_values = linspace(0, 20, nsteps);
IPR_over_W = cell(1, nsteps);
eigenvalues_cell = cell(nr, nsteps);
for W_index = 1:nsteps
W = W_values(W_index);
IPRs_for_this_W = zeros(1, nr);
for ir = 1:nr
H = generate_hamiltonian(L, W);
[eigenstates, D] = eig(H);
eigenvalues = diag(D);
energy_levels{ir} = eigenvalues(:)’;
IPR{ir} = compute_IPR(eigenstates);
IPRs_for_this_W(ir) = mean(IPR{ir});
% Store the eigenvalues in a cell array
eigenvalues_cell{ir, W_index} = eigenvalues(:)’;
end
% Store the mean IPR over 100 realizations for this W value
IPR_over_W{W_index} = mean(IPRs_for_this_W);
disp([W, IPR_over_W{W_index}])
end
%
% Create a figure for the color plot
figure;
% Define the colormap and use the IPR values for coloring
cmap = jet;
% Loop over W values
for W_index = 1:nsteps
W = W_values(W_index);
% Extract eigenvalues from the cell array
eigenvalues_for_W = eigenvalues_cell(:, W_index);
% Initialize arrays to store eigenvalues and y-axis values
eigenvalues_numeric = [];
y_values = [];
cdata = []; % Initialize color data
% Convert eigenvalues_for_W to a numeric array and create y_values
for ir = 1:nr
eigenvalues_ir = eigenvalues_for_W{ir};
eigenvalues_numeric = [eigenvalues_numeric, eigenvalues_ir];
y_values = [y_values, W * ones(size(eigenvalues_ir))];
% Calculate IPR values (You should have a function for this)
IPR_value = compute_IPR(eigenvalues_ir);
cdata = [cdata, IPR_value];
end
% Create a scatter plot with eigenvalues on the x-axis and y_values on the y-axis
scatter(eigenvalues_numeric, y_values, 20, cdata*1e-4, ‘filled’);
% imagesc(W_values, 1:nr, IPR_matrix);
colormap(cmap);
colorbar; % Add a colorbar
hold on;
end
xlabel(‘Eigenvalues’);
ylabel(‘W’);
title(‘Color Plot: Eigenvalues vs. W vs. IPR’);
hold off;
%%% box disorder
function disorder = generate_disorder(L, W)
disorder = W * ((rand(L, L, L) – 0.5));
end
% Generate the Hamiltonian matrix for one realization of the random disorder
function H = generate_hamiltonian(L, W)
H = zeros(L * L * L, L * L * L);
disorder = generate_disorder(L, W);
for i = 1:L
ip1 = mod(i, L) + 1;
for j = 1:L
jp1 = mod(j, L) + 1;
for k = 1:L
kp1 = mod(k, L) + 1;
H((i – 1) * L * L + (j – 1) * L + k, (i – 1) * L * L + (j – 1) * L + k) = disorder(i, j, k);
H(ip1 * L * L + j * L + k, (i – 1) * L * L + j * L + k) = 1.0;
H((i – 1) * L * L + jp1 * L + k, (i – 1) * L * L + j * L + k) = 1.0;
H((i – 1) * L * L + j * L + kp1, (i – 1) * L * L + j * L + k) = 1.0;
H((i – 1) * L * L + j * L + k, ip1 * L * L + j * L + k) = 1.0;
H((i – 1) * L * L + j * L + k, (i – 1) * L * L + jp1 * L + k) = 1.0;
H((i – 1) * L * L + j * L + k, (i – 1) * L * L + j * L + kp1) = 1.0;
end
end
end
end
function IPR = compute_IPR(eigenstates)
IPR = sum(abs(eigenstates).^4, 1);
endL = 10; % system size
nr = 10;
nsteps = 100;
W_values = linspace(0, 20, nsteps);
IPR_over_W = cell(1, nsteps);
eigenvalues_cell = cell(nr, nsteps);
for W_index = 1:nsteps
W = W_values(W_index);
IPRs_for_this_W = zeros(1, nr);
for ir = 1:nr
H = generate_hamiltonian(L, W);
[eigenstates, D] = eig(H);
eigenvalues = diag(D);
energy_levels{ir} = eigenvalues(:)’;
IPR{ir} = compute_IPR(eigenstates);
IPRs_for_this_W(ir) = mean(IPR{ir});
% Store the eigenvalues in a cell array
eigenvalues_cell{ir, W_index} = eigenvalues(:)’;
end
% Store the mean IPR over 100 realizations for this W value
IPR_over_W{W_index} = mean(IPRs_for_this_W);
disp([W, IPR_over_W{W_index}])
end
%
% Create a figure for the color plot
figure;
% Define the colormap and use the IPR values for coloring
cmap = jet;
% Loop over W values
for W_index = 1:nsteps
W = W_values(W_index);
% Extract eigenvalues from the cell array
eigenvalues_for_W = eigenvalues_cell(:, W_index);
% Initialize arrays to store eigenvalues and y-axis values
eigenvalues_numeric = [];
y_values = [];
cdata = []; % Initialize color data
% Convert eigenvalues_for_W to a numeric array and create y_values
for ir = 1:nr
eigenvalues_ir = eigenvalues_for_W{ir};
eigenvalues_numeric = [eigenvalues_numeric, eigenvalues_ir];
y_values = [y_values, W * ones(size(eigenvalues_ir))];
% Calculate IPR values (You should have a function for this)
IPR_value = compute_IPR(eigenvalues_ir);
cdata = [cdata, IPR_value];
end
% Create a scatter plot with eigenvalues on the x-axis and y_values on the y-axis
scatter(eigenvalues_numeric, y_values, 20, cdata*1e-4, ‘filled’);
% imagesc(W_values, 1:nr, IPR_matrix);
colormap(cmap);
colorbar; % Add a colorbar
hold on;
end
xlabel(‘Eigenvalues’);
ylabel(‘W’);
title(‘Color Plot: Eigenvalues vs. W vs. IPR’);
hold off;
%%% box disorder
function disorder = generate_disorder(L, W)
disorder = W * ((rand(L, L, L) – 0.5));
end
% Generate the Hamiltonian matrix for one realization of the random disorder
function H = generate_hamiltonian(L, W)
H = zeros(L * L * L, L * L * L);
disorder = generate_disorder(L, W);
for i = 1:L
ip1 = mod(i, L) + 1;
for j = 1:L
jp1 = mod(j, L) + 1;
for k = 1:L
kp1 = mod(k, L) + 1;
H((i – 1) * L * L + (j – 1) * L + k, (i – 1) * L * L + (j – 1) * L + k) = disorder(i, j, k);
H(ip1 * L * L + j * L + k, (i – 1) * L * L + j * L + k) = 1.0;
H((i – 1) * L * L + jp1 * L + k, (i – 1) * L * L + j * L + k) = 1.0;
H((i – 1) * L * L + j * L + kp1, (i – 1) * L * L + j * L + k) = 1.0;
H((i – 1) * L * L + j * L + k, ip1 * L * L + j * L + k) = 1.0;
H((i – 1) * L * L + j * L + k, (i – 1) * L * L + jp1 * L + k) = 1.0;
H((i – 1) * L * L + j * L + k, (i – 1) * L * L + j * L + kp1) = 1.0;
end
end
end
end
function IPR = compute_IPR(eigenstates)
IPR = sum(abs(eigenstates).^4, 1);
end L = 10; % system size
nr = 10;
nsteps = 100;
W_values = linspace(0, 20, nsteps);
IPR_over_W = cell(1, nsteps);
eigenvalues_cell = cell(nr, nsteps);
for W_index = 1:nsteps
W = W_values(W_index);
IPRs_for_this_W = zeros(1, nr);
for ir = 1:nr
H = generate_hamiltonian(L, W);
[eigenstates, D] = eig(H);
eigenvalues = diag(D);
energy_levels{ir} = eigenvalues(:)’;
IPR{ir} = compute_IPR(eigenstates);
IPRs_for_this_W(ir) = mean(IPR{ir});
% Store the eigenvalues in a cell array
eigenvalues_cell{ir, W_index} = eigenvalues(:)’;
end
% Store the mean IPR over 100 realizations for this W value
IPR_over_W{W_index} = mean(IPRs_for_this_W);
disp([W, IPR_over_W{W_index}])
end
%
% Create a figure for the color plot
figure;
% Define the colormap and use the IPR values for coloring
cmap = jet;
% Loop over W values
for W_index = 1:nsteps
W = W_values(W_index);
% Extract eigenvalues from the cell array
eigenvalues_for_W = eigenvalues_cell(:, W_index);
% Initialize arrays to store eigenvalues and y-axis values
eigenvalues_numeric = [];
y_values = [];
cdata = []; % Initialize color data
% Convert eigenvalues_for_W to a numeric array and create y_values
for ir = 1:nr
eigenvalues_ir = eigenvalues_for_W{ir};
eigenvalues_numeric = [eigenvalues_numeric, eigenvalues_ir];
y_values = [y_values, W * ones(size(eigenvalues_ir))];
% Calculate IPR values (You should have a function for this)
IPR_value = compute_IPR(eigenvalues_ir);
cdata = [cdata, IPR_value];
end
% Create a scatter plot with eigenvalues on the x-axis and y_values on the y-axis
scatter(eigenvalues_numeric, y_values, 20, cdata*1e-4, ‘filled’);
% imagesc(W_values, 1:nr, IPR_matrix);
colormap(cmap);
colorbar; % Add a colorbar
hold on;
end
xlabel(‘Eigenvalues’);
ylabel(‘W’);
title(‘Color Plot: Eigenvalues vs. W vs. IPR’);
hold off;
%%% box disorder
function disorder = generate_disorder(L, W)
disorder = W * ((rand(L, L, L) – 0.5));
end
% Generate the Hamiltonian matrix for one realization of the random disorder
function H = generate_hamiltonian(L, W)
H = zeros(L * L * L, L * L * L);
disorder = generate_disorder(L, W);
for i = 1:L
ip1 = mod(i, L) + 1;
for j = 1:L
jp1 = mod(j, L) + 1;
for k = 1:L
kp1 = mod(k, L) + 1;
H((i – 1) * L * L + (j – 1) * L + k, (i – 1) * L * L + (j – 1) * L + k) = disorder(i, j, k);
H(ip1 * L * L + j * L + k, (i – 1) * L * L + j * L + k) = 1.0;
H((i – 1) * L * L + jp1 * L + k, (i – 1) * L * L + j * L + k) = 1.0;
H((i – 1) * L * L + j * L + kp1, (i – 1) * L * L + j * L + k) = 1.0;
H((i – 1) * L * L + j * L + k, ip1 * L * L + j * L + k) = 1.0;
H((i – 1) * L * L + j * L + k, (i – 1) * L * L + jp1 * L + k) = 1.0;
H((i – 1) * L * L + j * L + k, (i – 1) * L * L + j * L + kp1) = 1.0;
end
end
end
end
function IPR = compute_IPR(eigenstates)
IPR = sum(abs(eigenstates).^4, 1);
end colormap MATLAB Answers — New Questions
Pipe (TL) fluid compressibility problem
Hello whenever I uncheck the compressibility box my model can’t run anymore can anyone help please.Hello whenever I uncheck the compressibility box my model can’t run anymore can anyone help please. Hello whenever I uncheck the compressibility box my model can’t run anymore can anyone help please. simscape, simulink, simulation, problem MATLAB Answers — New Questions
How to avoid the overshoot in Jiles Atherton hysteresis loop
Trying to plot a hysteresis model using jiles atherton hysteresis model in matlab. All the parameters are defined in the beginning.
Here is the code I have written,
clear
%% Given parameters
a = 512;
c = 0.75;
k = 570;
M_s = 1.7*10^6;
i_s = 10^-6;
alpha = 0.032;
u_0 = 4*pi*10^-7;
f = 1;
h_max = 8000;
%% Generate time vector
t_start = 0; %start time
t_end = 60; %end time
dt = 0.001; %time steps
t = t_start:dt:t_end;
%% Initial values
M_irev(1) = 0; %Initial irreversible magnetization
h = h_max*sin(2*pi*f*t); % Sinusoidal magnetic field strength
%% Time stepping loop
for i=2:length(t)
% Compute effective field
h_e = h(i); % Applied field and effective field considered equal
% Compute anhysteric magnetization
M_an = M_s*(coth(h_e/a) – (a/(h_e))); % Langevin function
% Compute derivative of magnetic field with respect to time
dh_e = (h(i) – h(i-1)) / dt;
delta = sign(dh_e);
% Compute irreversible magnetization using Euler method
M_irev(i) = ((M_an – M_irev(i-1)) / ((k * delta) – (alpha * (M_an – M_irev(i-1))))) * dh_e;
% Update magnetization
M(i) = c*M_an + (1-c)*M_irev(i);
end
%% Magnetic flux density
B = u_0 * (h + M);
%% Plot results
figure;
plot(h, B);
xlabel(‘Magnetic Field Strength’);
ylabel(‘Magnetic Flux Density’);
title(‘HB Graph’);
grid on;
The problem I am facing is when it plots the curve, it shows overshoot at three points. Suspecting the problem is in the ‘Langevin function’. Lower values of h at the end part creates bigger values thus it shows overshoot at those points. I think I need to use approximation (Taylor series or similar method) at those points so that when overshoot happens the code will avoid those overshoots and take the approximation. Can anyone show me how can I do that approximation?Trying to plot a hysteresis model using jiles atherton hysteresis model in matlab. All the parameters are defined in the beginning.
Here is the code I have written,
clear
%% Given parameters
a = 512;
c = 0.75;
k = 570;
M_s = 1.7*10^6;
i_s = 10^-6;
alpha = 0.032;
u_0 = 4*pi*10^-7;
f = 1;
h_max = 8000;
%% Generate time vector
t_start = 0; %start time
t_end = 60; %end time
dt = 0.001; %time steps
t = t_start:dt:t_end;
%% Initial values
M_irev(1) = 0; %Initial irreversible magnetization
h = h_max*sin(2*pi*f*t); % Sinusoidal magnetic field strength
%% Time stepping loop
for i=2:length(t)
% Compute effective field
h_e = h(i); % Applied field and effective field considered equal
% Compute anhysteric magnetization
M_an = M_s*(coth(h_e/a) – (a/(h_e))); % Langevin function
% Compute derivative of magnetic field with respect to time
dh_e = (h(i) – h(i-1)) / dt;
delta = sign(dh_e);
% Compute irreversible magnetization using Euler method
M_irev(i) = ((M_an – M_irev(i-1)) / ((k * delta) – (alpha * (M_an – M_irev(i-1))))) * dh_e;
% Update magnetization
M(i) = c*M_an + (1-c)*M_irev(i);
end
%% Magnetic flux density
B = u_0 * (h + M);
%% Plot results
figure;
plot(h, B);
xlabel(‘Magnetic Field Strength’);
ylabel(‘Magnetic Flux Density’);
title(‘HB Graph’);
grid on;
The problem I am facing is when it plots the curve, it shows overshoot at three points. Suspecting the problem is in the ‘Langevin function’. Lower values of h at the end part creates bigger values thus it shows overshoot at those points. I think I need to use approximation (Taylor series or similar method) at those points so that when overshoot happens the code will avoid those overshoots and take the approximation. Can anyone show me how can I do that approximation? Trying to plot a hysteresis model using jiles atherton hysteresis model in matlab. All the parameters are defined in the beginning.
Here is the code I have written,
clear
%% Given parameters
a = 512;
c = 0.75;
k = 570;
M_s = 1.7*10^6;
i_s = 10^-6;
alpha = 0.032;
u_0 = 4*pi*10^-7;
f = 1;
h_max = 8000;
%% Generate time vector
t_start = 0; %start time
t_end = 60; %end time
dt = 0.001; %time steps
t = t_start:dt:t_end;
%% Initial values
M_irev(1) = 0; %Initial irreversible magnetization
h = h_max*sin(2*pi*f*t); % Sinusoidal magnetic field strength
%% Time stepping loop
for i=2:length(t)
% Compute effective field
h_e = h(i); % Applied field and effective field considered equal
% Compute anhysteric magnetization
M_an = M_s*(coth(h_e/a) – (a/(h_e))); % Langevin function
% Compute derivative of magnetic field with respect to time
dh_e = (h(i) – h(i-1)) / dt;
delta = sign(dh_e);
% Compute irreversible magnetization using Euler method
M_irev(i) = ((M_an – M_irev(i-1)) / ((k * delta) – (alpha * (M_an – M_irev(i-1))))) * dh_e;
% Update magnetization
M(i) = c*M_an + (1-c)*M_irev(i);
end
%% Magnetic flux density
B = u_0 * (h + M);
%% Plot results
figure;
plot(h, B);
xlabel(‘Magnetic Field Strength’);
ylabel(‘Magnetic Flux Density’);
title(‘HB Graph’);
grid on;
The problem I am facing is when it plots the curve, it shows overshoot at three points. Suspecting the problem is in the ‘Langevin function’. Lower values of h at the end part creates bigger values thus it shows overshoot at those points. I think I need to use approximation (Taylor series or similar method) at those points so that when overshoot happens the code will avoid those overshoots and take the approximation. Can anyone show me how can I do that approximation? jiles-atherton, hysteresis, approximation, taylor series MATLAB Answers — New Questions
Property set method for structure-like property
Hello, I’m implementing a class (used to control an instrument through a USB interface).
Due to the structure of the instrument, I’d like to store properies as structures.
I wonder if there is a good way to implement property set method which would only update the field that was changed.
Here is what I have know:
classdef Driver < handle
properties
input; % Structure array with input settings
% – range
% – ac (coupling: AC/DC)
% – impedance_50ohm (50/1e6)
output; % Structure array with output settings
% – on
% – range (V)
% – amplitude (V, peak-to-peak)
% – mixer (channel)
end
methods
% Getters
function input = get.input(obj)
range = obj.get(‘input_range’);
ac = obj.get(‘input_ac’);
impedance_50ohm = obj.get(‘input_impedance_50’);
input = struct(‘range’, range, ‘ac’, ac, ‘impedance_50ohm’, impedance_50ohm);
end
function output = get.output(obj)
on = obj.get(‘output_on’);
range = obj.get(‘output_range’);
amplitude = obj.get(‘output_amplitude’);
mixer = obj.get(‘output_mixer’);
output = struct(‘on’, on, ‘range’, range, ‘amplitude’, amplitude, ‘mixer’, mixer);
end
% Setters
function set.input(obj, input)
obj.set(‘input_range’, input.range);
obj.set(‘input_ac’, input.ac);
obj.set(‘input_impedance_50’, input.impedance_50ohm);
end
function set.output(obj, output)
obj.set(‘output_on’, output.on);
obj.set(‘output_range’, output.range);
obj.set(‘output_amplitude’, output.amplitude);
obj.set(‘output_mixer’, output.mixer);
end
end
end
However, I do not want to update all the field each time one field is changed. I want to do something like (obviously this not a proper code):
classdef Driver < handle
properties
input; % Structure array with input settings
% – range
% – ac (coupling: AC/DC)
% – impedance_50ohm (50/1e6)
output; % Structure array with output settings
% – on
% – range (V)
% – amplitude (V, peak-to-peak)
% – mixer (channel)
end
methods
% Getters
function range = get.input.range(obj)
range = obj.get(‘input_range’);
end
function ac = get.input.ac(obj)
ac = obj.get(‘input_ac’);
end
%etc…
% Setters
function set.input.range(obj, input.range)
obj.set(‘input_range’, input.range);
end
function set.input.ac(obj, input.ac)
obj.set(‘input_ac’, input.ac);
end
%etc…
end
end
I understand that I could just make them separate properties, but this would be not a pleasing solution.
classdef Driver < handle
properties
%Input Parameters
input_range; % Input ranges of all signal inputs
input_ac; % Input couplings of all signal inputs
input_impedance_50; % Input impedances of all signal inputs
%Output Parameters
output_on; % Output status of all signal outputs
output_range; % Output ranges of all signal outputs
output_amplitude; % Output amplitudes of all signal outputs
output_mixer; % Output mixer channels of all signal outputs
end
end
Thank you.Hello, I’m implementing a class (used to control an instrument through a USB interface).
Due to the structure of the instrument, I’d like to store properies as structures.
I wonder if there is a good way to implement property set method which would only update the field that was changed.
Here is what I have know:
classdef Driver < handle
properties
input; % Structure array with input settings
% – range
% – ac (coupling: AC/DC)
% – impedance_50ohm (50/1e6)
output; % Structure array with output settings
% – on
% – range (V)
% – amplitude (V, peak-to-peak)
% – mixer (channel)
end
methods
% Getters
function input = get.input(obj)
range = obj.get(‘input_range’);
ac = obj.get(‘input_ac’);
impedance_50ohm = obj.get(‘input_impedance_50’);
input = struct(‘range’, range, ‘ac’, ac, ‘impedance_50ohm’, impedance_50ohm);
end
function output = get.output(obj)
on = obj.get(‘output_on’);
range = obj.get(‘output_range’);
amplitude = obj.get(‘output_amplitude’);
mixer = obj.get(‘output_mixer’);
output = struct(‘on’, on, ‘range’, range, ‘amplitude’, amplitude, ‘mixer’, mixer);
end
% Setters
function set.input(obj, input)
obj.set(‘input_range’, input.range);
obj.set(‘input_ac’, input.ac);
obj.set(‘input_impedance_50’, input.impedance_50ohm);
end
function set.output(obj, output)
obj.set(‘output_on’, output.on);
obj.set(‘output_range’, output.range);
obj.set(‘output_amplitude’, output.amplitude);
obj.set(‘output_mixer’, output.mixer);
end
end
end
However, I do not want to update all the field each time one field is changed. I want to do something like (obviously this not a proper code):
classdef Driver < handle
properties
input; % Structure array with input settings
% – range
% – ac (coupling: AC/DC)
% – impedance_50ohm (50/1e6)
output; % Structure array with output settings
% – on
% – range (V)
% – amplitude (V, peak-to-peak)
% – mixer (channel)
end
methods
% Getters
function range = get.input.range(obj)
range = obj.get(‘input_range’);
end
function ac = get.input.ac(obj)
ac = obj.get(‘input_ac’);
end
%etc…
% Setters
function set.input.range(obj, input.range)
obj.set(‘input_range’, input.range);
end
function set.input.ac(obj, input.ac)
obj.set(‘input_ac’, input.ac);
end
%etc…
end
end
I understand that I could just make them separate properties, but this would be not a pleasing solution.
classdef Driver < handle
properties
%Input Parameters
input_range; % Input ranges of all signal inputs
input_ac; % Input couplings of all signal inputs
input_impedance_50; % Input impedances of all signal inputs
%Output Parameters
output_on; % Output status of all signal outputs
output_range; % Output ranges of all signal outputs
output_amplitude; % Output amplitudes of all signal outputs
output_mixer; % Output mixer channels of all signal outputs
end
end
Thank you. Hello, I’m implementing a class (used to control an instrument through a USB interface).
Due to the structure of the instrument, I’d like to store properies as structures.
I wonder if there is a good way to implement property set method which would only update the field that was changed.
Here is what I have know:
classdef Driver < handle
properties
input; % Structure array with input settings
% – range
% – ac (coupling: AC/DC)
% – impedance_50ohm (50/1e6)
output; % Structure array with output settings
% – on
% – range (V)
% – amplitude (V, peak-to-peak)
% – mixer (channel)
end
methods
% Getters
function input = get.input(obj)
range = obj.get(‘input_range’);
ac = obj.get(‘input_ac’);
impedance_50ohm = obj.get(‘input_impedance_50’);
input = struct(‘range’, range, ‘ac’, ac, ‘impedance_50ohm’, impedance_50ohm);
end
function output = get.output(obj)
on = obj.get(‘output_on’);
range = obj.get(‘output_range’);
amplitude = obj.get(‘output_amplitude’);
mixer = obj.get(‘output_mixer’);
output = struct(‘on’, on, ‘range’, range, ‘amplitude’, amplitude, ‘mixer’, mixer);
end
% Setters
function set.input(obj, input)
obj.set(‘input_range’, input.range);
obj.set(‘input_ac’, input.ac);
obj.set(‘input_impedance_50’, input.impedance_50ohm);
end
function set.output(obj, output)
obj.set(‘output_on’, output.on);
obj.set(‘output_range’, output.range);
obj.set(‘output_amplitude’, output.amplitude);
obj.set(‘output_mixer’, output.mixer);
end
end
end
However, I do not want to update all the field each time one field is changed. I want to do something like (obviously this not a proper code):
classdef Driver < handle
properties
input; % Structure array with input settings
% – range
% – ac (coupling: AC/DC)
% – impedance_50ohm (50/1e6)
output; % Structure array with output settings
% – on
% – range (V)
% – amplitude (V, peak-to-peak)
% – mixer (channel)
end
methods
% Getters
function range = get.input.range(obj)
range = obj.get(‘input_range’);
end
function ac = get.input.ac(obj)
ac = obj.get(‘input_ac’);
end
%etc…
% Setters
function set.input.range(obj, input.range)
obj.set(‘input_range’, input.range);
end
function set.input.ac(obj, input.ac)
obj.set(‘input_ac’, input.ac);
end
%etc…
end
end
I understand that I could just make them separate properties, but this would be not a pleasing solution.
classdef Driver < handle
properties
%Input Parameters
input_range; % Input ranges of all signal inputs
input_ac; % Input couplings of all signal inputs
input_impedance_50; % Input impedances of all signal inputs
%Output Parameters
output_on; % Output status of all signal outputs
output_range; % Output ranges of all signal outputs
output_amplitude; % Output amplitudes of all signal outputs
output_mixer; % Output mixer channels of all signal outputs
end
end
Thank you. setter, getter, class, property, structures MATLAB Answers — New Questions
Trying to adjust weighting on PART of a sigmoid fit
I included a picture of the current fit that I am getting, what is in black is the actual data. So far the fit is pretty good but my PI would like it to fit a bit better and he suggested weighting the first part of the fit less than the later parts since we really only care from about 500 seconds onwards. Any suggestions on how to do this? I can include the actual matlab file for the fit if that would be helpful for anyone
Thanks!I included a picture of the current fit that I am getting, what is in black is the actual data. So far the fit is pretty good but my PI would like it to fit a bit better and he suggested weighting the first part of the fit less than the later parts since we really only care from about 500 seconds onwards. Any suggestions on how to do this? I can include the actual matlab file for the fit if that would be helpful for anyone
Thanks! I included a picture of the current fit that I am getting, what is in black is the actual data. So far the fit is pretty good but my PI would like it to fit a bit better and he suggested weighting the first part of the fit less than the later parts since we really only care from about 500 seconds onwards. Any suggestions on how to do this? I can include the actual matlab file for the fit if that would be helpful for anyone
Thanks! sigmoid, image processing, curve fitting MATLAB Answers — New Questions
Get the Isocline from a know levelset plot (Contours) and the function output (Height)
I was checking the function fcontour that we can use to get the contours like the following one.
I took the given example:
f = @(x,y) exp(-(x/3).^2-(y/3).^2) + exp(-(x+2).^2-(y+2).^2);
fc = fcontour(f)
Now, I would like to see the heights of each contour.
Suppose I have the height value, how do I get the points that belong the contour that corresponds to the height.
Regards…I was checking the function fcontour that we can use to get the contours like the following one.
I took the given example:
f = @(x,y) exp(-(x/3).^2-(y/3).^2) + exp(-(x+2).^2-(y+2).^2);
fc = fcontour(f)
Now, I would like to see the heights of each contour.
Suppose I have the height value, how do I get the points that belong the contour that corresponds to the height.
Regards… I was checking the function fcontour that we can use to get the contours like the following one.
I took the given example:
f = @(x,y) exp(-(x/3).^2-(y/3).^2) + exp(-(x+2).^2-(y+2).^2);
fc = fcontour(f)
Now, I would like to see the heights of each contour.
Suppose I have the height value, how do I get the points that belong the contour that corresponds to the height.
Regards… fcontour, levelset, isoclines MATLAB Answers — New Questions
Creating a loop for repeated vector values
Hi,
I am attempting to setup a massive vector made up of Current values for a battery model. Before this piece of code I have included, the PosAccelReqCurrent already has 15 values. Is it possible to make a loop to repeat the values below for x amount of times rather than just copy and pasting it x times? It would make my code a lot of more efficient rather than having thousands of lines of the same code.
As further context, this code is to create many repeated current cycles to test battery degredation over time. Apologies if I have not added enough explanation.
Thank you.
%%%%%%%%%%%%%%%
maxPARC = length(PosAccelReqCurrent);
for x=1:6500
PosAccelReqCurrent(maxPARC+x)=PosAccelReqCurrent(15);
end
for x=1:6500
ActVel(maxPARC+x)=ActVel(15);
end
maxPARC = length(PosAccelReqCurrent);
for x=1:100
PosAccelReqCurrent(maxPARC+x)=0;
end
for x=1:100
ActVel(maxPARC+x)=ActVel(15);
end
maxPARC = length(PosAccelReqCurrent);
for x=1:3470
PosAccelReqCurrent(maxPARC+x)=15;
end
for x=1:3470
ActVel(maxPARC+x)=0;
end
%%%%%%%%%%%%%%%%%%%%Hi,
I am attempting to setup a massive vector made up of Current values for a battery model. Before this piece of code I have included, the PosAccelReqCurrent already has 15 values. Is it possible to make a loop to repeat the values below for x amount of times rather than just copy and pasting it x times? It would make my code a lot of more efficient rather than having thousands of lines of the same code.
As further context, this code is to create many repeated current cycles to test battery degredation over time. Apologies if I have not added enough explanation.
Thank you.
%%%%%%%%%%%%%%%
maxPARC = length(PosAccelReqCurrent);
for x=1:6500
PosAccelReqCurrent(maxPARC+x)=PosAccelReqCurrent(15);
end
for x=1:6500
ActVel(maxPARC+x)=ActVel(15);
end
maxPARC = length(PosAccelReqCurrent);
for x=1:100
PosAccelReqCurrent(maxPARC+x)=0;
end
for x=1:100
ActVel(maxPARC+x)=ActVel(15);
end
maxPARC = length(PosAccelReqCurrent);
for x=1:3470
PosAccelReqCurrent(maxPARC+x)=15;
end
for x=1:3470
ActVel(maxPARC+x)=0;
end
%%%%%%%%%%%%%%%%%%%% Hi,
I am attempting to setup a massive vector made up of Current values for a battery model. Before this piece of code I have included, the PosAccelReqCurrent already has 15 values. Is it possible to make a loop to repeat the values below for x amount of times rather than just copy and pasting it x times? It would make my code a lot of more efficient rather than having thousands of lines of the same code.
As further context, this code is to create many repeated current cycles to test battery degredation over time. Apologies if I have not added enough explanation.
Thank you.
%%%%%%%%%%%%%%%
maxPARC = length(PosAccelReqCurrent);
for x=1:6500
PosAccelReqCurrent(maxPARC+x)=PosAccelReqCurrent(15);
end
for x=1:6500
ActVel(maxPARC+x)=ActVel(15);
end
maxPARC = length(PosAccelReqCurrent);
for x=1:100
PosAccelReqCurrent(maxPARC+x)=0;
end
for x=1:100
ActVel(maxPARC+x)=ActVel(15);
end
maxPARC = length(PosAccelReqCurrent);
for x=1:3470
PosAccelReqCurrent(maxPARC+x)=15;
end
for x=1:3470
ActVel(maxPARC+x)=0;
end
%%%%%%%%%%%%%%%%%%%% loops, batterymodel MATLAB Answers — New Questions
Processing 5 input of matrices into a fuzzy logic system
Sir Arkadiy Turevskiy,
I read your answer about ‘Processing a list of inputs into a fuzzy logic system. I have a similar question, I want to process 5 input matrices (207*216) to take 1 output matrices (207*216). I have five separate matrices text file loaded in workspace(input1=slope_text, input2=jeo_text, input3=pop_text, input4=land_text, input5=stream_text)
[System]
Name=’Suitability2′
Type=’mamdani’
Version=2.0
NumInputs=5
NumOutputs=1
NumRules=108
AndMethod=’min’
OrMethod=’max’
ImpMethod=’min’
AggMethod=’max’
DefuzzMethod=’centroid’
[Input1]
Name=’EĞİM’
Range=[0 10]
NumMFs=3
MF1=’very_suitable’:’trapmf’,[-4.5 -0.5 2 5]
MF2=’moderately_suitable’:’trapmf’,[2 5 7 10]
MF3=’unsuitable’:’trapmf’,[7 10 11 40]
[Input2]
Name=’JEOLOJİ’
Range=[0 10]
NumMFs=2
MF1=’suitable’:’trapmf’,[4 8 10 13.75]
MF2=’unsuitable’:’trapmf’,[-4.5 -2 1 2]
[Input3]
Name=’NÜFUS’
Range=[0 98399]
NumMFs=3
MF1=’LOW’:’trimf’,[0 9976 25470]
MF2=’HIGH’:’trimf’,[72460 98400 1000000]
MF3=’medium’:’trimf’,[25470 46380 72460]
[Input4]
Name=’ARAZİ_KULLANIMI’
Range=[0 10]
NumMFs=2
MF1=’Unsuitable’:’trimf’,[0 0 6]
MF2=’Suitable’:’trimf’,[6 10 10]
[Input5]
Name=’YÜZEYSEL_AKIŞ’
Range=[0 10]
NumMFs=3
MF1=’low’:’trimf’,[1 2 3]
MF2=’high’:’trimf’,[5 6 7]
MF3=’medium’:’trimf’,[3 4 5]
[Output1]
Name=’UYGUNLUK_DEĞERİ’
Range=[0 100]
NumMFs=3
MF1=’POOR’:’trapmf’,[-4.46 0 10 40]
MF2=’GOOD’:’trimf’,[25 50 75]
MF3=’EXCELLENT’:’trapmf’,[60 90 100 100]Sir Arkadiy Turevskiy,
I read your answer about ‘Processing a list of inputs into a fuzzy logic system. I have a similar question, I want to process 5 input matrices (207*216) to take 1 output matrices (207*216). I have five separate matrices text file loaded in workspace(input1=slope_text, input2=jeo_text, input3=pop_text, input4=land_text, input5=stream_text)
[System]
Name=’Suitability2′
Type=’mamdani’
Version=2.0
NumInputs=5
NumOutputs=1
NumRules=108
AndMethod=’min’
OrMethod=’max’
ImpMethod=’min’
AggMethod=’max’
DefuzzMethod=’centroid’
[Input1]
Name=’EĞİM’
Range=[0 10]
NumMFs=3
MF1=’very_suitable’:’trapmf’,[-4.5 -0.5 2 5]
MF2=’moderately_suitable’:’trapmf’,[2 5 7 10]
MF3=’unsuitable’:’trapmf’,[7 10 11 40]
[Input2]
Name=’JEOLOJİ’
Range=[0 10]
NumMFs=2
MF1=’suitable’:’trapmf’,[4 8 10 13.75]
MF2=’unsuitable’:’trapmf’,[-4.5 -2 1 2]
[Input3]
Name=’NÜFUS’
Range=[0 98399]
NumMFs=3
MF1=’LOW’:’trimf’,[0 9976 25470]
MF2=’HIGH’:’trimf’,[72460 98400 1000000]
MF3=’medium’:’trimf’,[25470 46380 72460]
[Input4]
Name=’ARAZİ_KULLANIMI’
Range=[0 10]
NumMFs=2
MF1=’Unsuitable’:’trimf’,[0 0 6]
MF2=’Suitable’:’trimf’,[6 10 10]
[Input5]
Name=’YÜZEYSEL_AKIŞ’
Range=[0 10]
NumMFs=3
MF1=’low’:’trimf’,[1 2 3]
MF2=’high’:’trimf’,[5 6 7]
MF3=’medium’:’trimf’,[3 4 5]
[Output1]
Name=’UYGUNLUK_DEĞERİ’
Range=[0 100]
NumMFs=3
MF1=’POOR’:’trapmf’,[-4.46 0 10 40]
MF2=’GOOD’:’trimf’,[25 50 75]
MF3=’EXCELLENT’:’trapmf’,[60 90 100 100] Sir Arkadiy Turevskiy,
I read your answer about ‘Processing a list of inputs into a fuzzy logic system. I have a similar question, I want to process 5 input matrices (207*216) to take 1 output matrices (207*216). I have five separate matrices text file loaded in workspace(input1=slope_text, input2=jeo_text, input3=pop_text, input4=land_text, input5=stream_text)
[System]
Name=’Suitability2′
Type=’mamdani’
Version=2.0
NumInputs=5
NumOutputs=1
NumRules=108
AndMethod=’min’
OrMethod=’max’
ImpMethod=’min’
AggMethod=’max’
DefuzzMethod=’centroid’
[Input1]
Name=’EĞİM’
Range=[0 10]
NumMFs=3
MF1=’very_suitable’:’trapmf’,[-4.5 -0.5 2 5]
MF2=’moderately_suitable’:’trapmf’,[2 5 7 10]
MF3=’unsuitable’:’trapmf’,[7 10 11 40]
[Input2]
Name=’JEOLOJİ’
Range=[0 10]
NumMFs=2
MF1=’suitable’:’trapmf’,[4 8 10 13.75]
MF2=’unsuitable’:’trapmf’,[-4.5 -2 1 2]
[Input3]
Name=’NÜFUS’
Range=[0 98399]
NumMFs=3
MF1=’LOW’:’trimf’,[0 9976 25470]
MF2=’HIGH’:’trimf’,[72460 98400 1000000]
MF3=’medium’:’trimf’,[25470 46380 72460]
[Input4]
Name=’ARAZİ_KULLANIMI’
Range=[0 10]
NumMFs=2
MF1=’Unsuitable’:’trimf’,[0 0 6]
MF2=’Suitable’:’trimf’,[6 10 10]
[Input5]
Name=’YÜZEYSEL_AKIŞ’
Range=[0 10]
NumMFs=3
MF1=’low’:’trimf’,[1 2 3]
MF2=’high’:’trimf’,[5 6 7]
MF3=’medium’:’trimf’,[3 4 5]
[Output1]
Name=’UYGUNLUK_DEĞERİ’
Range=[0 100]
NumMFs=3
MF1=’POOR’:’trapmf’,[-4.46 0 10 40]
MF2=’GOOD’:’trimf’,[25 50 75]
MF3=’EXCELLENT’:’trapmf’,[60 90 100 100] fuzzy logic MATLAB Answers — New Questions
Solving ODE system with a constraint/boundary condition
Hello,
I am trying to simulate a chemical reaction in a tubular reactor. The reaction is in this form: A -> B + 6 C.
The reaction is a gas phase reaction and the reaction rate is a function of the partial pressures of the three components. I solved the mass balances for steady state (and some other assumtions) and came up with these equations:
I implemented them as an ODE system and want to solve this system via ode45. The code runs without an error but the solution does not fulfill the physical boundary condition, that the sum of all partial pressure has to be the system pressure at all times, or at all positions.
Is there any way to implement a sort of boundary condition, which can be solved by ode45?
See my code below. Please consider that the values for the parameters are arbitrary.
%% Definition of constant parameters
d = 0.028; % tube diameter [m]
length = 0.84; % tube length [m]
A = pi()/4*d^2; % Area [m^2]
V_reactor = A*length; % Reaction volume [m^3]
m_kat = 0.3; % catalyst mass [kg]
rho_packing = m_kat/(V_reactor)*1000; % catalyst density [kg m^-3]
T_shell = 330; % Reaction temperature [°C]
T_shell = T_shell+273.15; % Reaction temperature [K]
p = 4; % reaction pressure [bara]
V_in = 5/60; %inlet stream [m^3 s^-1]
v_z = V_in/A; % velocity [m s^-1]
R = 8.314; % J mol^-1 K^-1
%Starting partial pressures
p_B_in = 1e-4;
p_C_in = 1e-4;
p_A_in = p-p_B_in-p_C_in;
T_in = T_shell;
%Reaction parameters
ReactionRate.k0 = 150;
ReactionRate.EA = 100000;
ReactionRate.a = -0.5;
ReactionRate.m = 1;
ReactionRate.n = -0.5;
%% Calculation of equilibrium constant
eq = @(p,T)(exp((0.06206+p.*0.00176).*((773.15-T)-(443.46876-99.02783.*log(p+5.73037)))))./(1+exp((0.06206+p*0.00176).*((773.15-T)-(443.46876-99.02783.*log(p+5.73037)))));
K_eq_function = @(p,T)((1-eq(p,T))/(eq(p,T)));
K_eq = K_eq_function(p,T_shell);
% Solving ODE system
dz = 0.01; %step size
[z,c] = ode45(@(z, c) ODE_System(z, c, v_z, rho_packing, ReactionRate, R, T_shell, K_eq),0:dz:1,[p_B_in, p_A_in, p_C_in]);
%%Definition of ODE system
function [ddz] = ODE_System(~,c,v_z,rho_packing,ReactionRate,R,T_shell,K_eq)
ddz(1) = ((R*T_shell)/v_z*rho_packing*(((c(3))^ReactionRate.a*ReactionRate.k0*exp(-ReactionRate.EA/ (R*T_shell))*(c(2))^ReactionRate.m*(c(1))^ReactionRate.n*(1-(c(1)/(c(2)*K_eq)))))); % mass balance for B
ddz(2) = (-(R*T_shell)/v_z*rho_packing*(((c(3))^ReactionRate.a*ReactionRate.k0*exp(-ReactionRate.EA/(R*T_shell))*(c(2))^ReactionRate.m*(c(1))^ReactionRate.n*(1-(c(1)/(c(2)*K_eq)))))); % mass balance for A
ddz(3) = 6*((R*T_shell)/v_z*rho_packing*(((c(3))^ReactionRate.a*ReactionRate.k0*exp(-ReactionRate.EA/(R*T_shell))*(c(2))^ReactionRate.m*(c(1))^ReactionRate.n*(1-(c(1)/(c(2)*K_eq)))))); % mass balance for C
ddz = ddz’;
end
The condition which has to be fulfilled at any time would be:
Thank you in advance.Hello,
I am trying to simulate a chemical reaction in a tubular reactor. The reaction is in this form: A -> B + 6 C.
The reaction is a gas phase reaction and the reaction rate is a function of the partial pressures of the three components. I solved the mass balances for steady state (and some other assumtions) and came up with these equations:
I implemented them as an ODE system and want to solve this system via ode45. The code runs without an error but the solution does not fulfill the physical boundary condition, that the sum of all partial pressure has to be the system pressure at all times, or at all positions.
Is there any way to implement a sort of boundary condition, which can be solved by ode45?
See my code below. Please consider that the values for the parameters are arbitrary.
%% Definition of constant parameters
d = 0.028; % tube diameter [m]
length = 0.84; % tube length [m]
A = pi()/4*d^2; % Area [m^2]
V_reactor = A*length; % Reaction volume [m^3]
m_kat = 0.3; % catalyst mass [kg]
rho_packing = m_kat/(V_reactor)*1000; % catalyst density [kg m^-3]
T_shell = 330; % Reaction temperature [°C]
T_shell = T_shell+273.15; % Reaction temperature [K]
p = 4; % reaction pressure [bara]
V_in = 5/60; %inlet stream [m^3 s^-1]
v_z = V_in/A; % velocity [m s^-1]
R = 8.314; % J mol^-1 K^-1
%Starting partial pressures
p_B_in = 1e-4;
p_C_in = 1e-4;
p_A_in = p-p_B_in-p_C_in;
T_in = T_shell;
%Reaction parameters
ReactionRate.k0 = 150;
ReactionRate.EA = 100000;
ReactionRate.a = -0.5;
ReactionRate.m = 1;
ReactionRate.n = -0.5;
%% Calculation of equilibrium constant
eq = @(p,T)(exp((0.06206+p.*0.00176).*((773.15-T)-(443.46876-99.02783.*log(p+5.73037)))))./(1+exp((0.06206+p*0.00176).*((773.15-T)-(443.46876-99.02783.*log(p+5.73037)))));
K_eq_function = @(p,T)((1-eq(p,T))/(eq(p,T)));
K_eq = K_eq_function(p,T_shell);
% Solving ODE system
dz = 0.01; %step size
[z,c] = ode45(@(z, c) ODE_System(z, c, v_z, rho_packing, ReactionRate, R, T_shell, K_eq),0:dz:1,[p_B_in, p_A_in, p_C_in]);
%%Definition of ODE system
function [ddz] = ODE_System(~,c,v_z,rho_packing,ReactionRate,R,T_shell,K_eq)
ddz(1) = ((R*T_shell)/v_z*rho_packing*(((c(3))^ReactionRate.a*ReactionRate.k0*exp(-ReactionRate.EA/ (R*T_shell))*(c(2))^ReactionRate.m*(c(1))^ReactionRate.n*(1-(c(1)/(c(2)*K_eq)))))); % mass balance for B
ddz(2) = (-(R*T_shell)/v_z*rho_packing*(((c(3))^ReactionRate.a*ReactionRate.k0*exp(-ReactionRate.EA/(R*T_shell))*(c(2))^ReactionRate.m*(c(1))^ReactionRate.n*(1-(c(1)/(c(2)*K_eq)))))); % mass balance for A
ddz(3) = 6*((R*T_shell)/v_z*rho_packing*(((c(3))^ReactionRate.a*ReactionRate.k0*exp(-ReactionRate.EA/(R*T_shell))*(c(2))^ReactionRate.m*(c(1))^ReactionRate.n*(1-(c(1)/(c(2)*K_eq)))))); % mass balance for C
ddz = ddz’;
end
The condition which has to be fulfilled at any time would be:
Thank you in advance. Hello,
I am trying to simulate a chemical reaction in a tubular reactor. The reaction is in this form: A -> B + 6 C.
The reaction is a gas phase reaction and the reaction rate is a function of the partial pressures of the three components. I solved the mass balances for steady state (and some other assumtions) and came up with these equations:
I implemented them as an ODE system and want to solve this system via ode45. The code runs without an error but the solution does not fulfill the physical boundary condition, that the sum of all partial pressure has to be the system pressure at all times, or at all positions.
Is there any way to implement a sort of boundary condition, which can be solved by ode45?
See my code below. Please consider that the values for the parameters are arbitrary.
%% Definition of constant parameters
d = 0.028; % tube diameter [m]
length = 0.84; % tube length [m]
A = pi()/4*d^2; % Area [m^2]
V_reactor = A*length; % Reaction volume [m^3]
m_kat = 0.3; % catalyst mass [kg]
rho_packing = m_kat/(V_reactor)*1000; % catalyst density [kg m^-3]
T_shell = 330; % Reaction temperature [°C]
T_shell = T_shell+273.15; % Reaction temperature [K]
p = 4; % reaction pressure [bara]
V_in = 5/60; %inlet stream [m^3 s^-1]
v_z = V_in/A; % velocity [m s^-1]
R = 8.314; % J mol^-1 K^-1
%Starting partial pressures
p_B_in = 1e-4;
p_C_in = 1e-4;
p_A_in = p-p_B_in-p_C_in;
T_in = T_shell;
%Reaction parameters
ReactionRate.k0 = 150;
ReactionRate.EA = 100000;
ReactionRate.a = -0.5;
ReactionRate.m = 1;
ReactionRate.n = -0.5;
%% Calculation of equilibrium constant
eq = @(p,T)(exp((0.06206+p.*0.00176).*((773.15-T)-(443.46876-99.02783.*log(p+5.73037)))))./(1+exp((0.06206+p*0.00176).*((773.15-T)-(443.46876-99.02783.*log(p+5.73037)))));
K_eq_function = @(p,T)((1-eq(p,T))/(eq(p,T)));
K_eq = K_eq_function(p,T_shell);
% Solving ODE system
dz = 0.01; %step size
[z,c] = ode45(@(z, c) ODE_System(z, c, v_z, rho_packing, ReactionRate, R, T_shell, K_eq),0:dz:1,[p_B_in, p_A_in, p_C_in]);
%%Definition of ODE system
function [ddz] = ODE_System(~,c,v_z,rho_packing,ReactionRate,R,T_shell,K_eq)
ddz(1) = ((R*T_shell)/v_z*rho_packing*(((c(3))^ReactionRate.a*ReactionRate.k0*exp(-ReactionRate.EA/ (R*T_shell))*(c(2))^ReactionRate.m*(c(1))^ReactionRate.n*(1-(c(1)/(c(2)*K_eq)))))); % mass balance for B
ddz(2) = (-(R*T_shell)/v_z*rho_packing*(((c(3))^ReactionRate.a*ReactionRate.k0*exp(-ReactionRate.EA/(R*T_shell))*(c(2))^ReactionRate.m*(c(1))^ReactionRate.n*(1-(c(1)/(c(2)*K_eq)))))); % mass balance for A
ddz(3) = 6*((R*T_shell)/v_z*rho_packing*(((c(3))^ReactionRate.a*ReactionRate.k0*exp(-ReactionRate.EA/(R*T_shell))*(c(2))^ReactionRate.m*(c(1))^ReactionRate.n*(1-(c(1)/(c(2)*K_eq)))))); % mass balance for C
ddz = ddz’;
end
The condition which has to be fulfilled at any time would be:
Thank you in advance. ode, ode45, boundary condition MATLAB Answers — New Questions
Write a string to hdf5 file with defined string length
I am trying to write a string to hdf5 file:
h5create(‘combo.hdf5′,’/description’,1,Datatype=’string’);
h5write(‘combo.hdf5′,’/description’,"this is the description");
When I read it out using h5disp, the result is:
Dataset ‘description’
Size: 1
MaxSize: 1
Datatype: H5T_STRING
String Length: variable
Padding: H5T_STR_NULLTERM
Character Set: H5T_CSET_UTF8
Character Type: H5T_C_S1
ChunkSize: []
Filters: none
FillValue: ”
Notice the String Length is denoted as ‘variable’. What if I want to define the length of this string (23 here), so it shows:
String Length: 23
Thank you very much!I am trying to write a string to hdf5 file:
h5create(‘combo.hdf5′,’/description’,1,Datatype=’string’);
h5write(‘combo.hdf5′,’/description’,"this is the description");
When I read it out using h5disp, the result is:
Dataset ‘description’
Size: 1
MaxSize: 1
Datatype: H5T_STRING
String Length: variable
Padding: H5T_STR_NULLTERM
Character Set: H5T_CSET_UTF8
Character Type: H5T_C_S1
ChunkSize: []
Filters: none
FillValue: ”
Notice the String Length is denoted as ‘variable’. What if I want to define the length of this string (23 here), so it shows:
String Length: 23
Thank you very much! I am trying to write a string to hdf5 file:
h5create(‘combo.hdf5′,’/description’,1,Datatype=’string’);
h5write(‘combo.hdf5′,’/description’,"this is the description");
When I read it out using h5disp, the result is:
Dataset ‘description’
Size: 1
MaxSize: 1
Datatype: H5T_STRING
String Length: variable
Padding: H5T_STR_NULLTERM
Character Set: H5T_CSET_UTF8
Character Type: H5T_C_S1
ChunkSize: []
Filters: none
FillValue: ”
Notice the String Length is denoted as ‘variable’. What if I want to define the length of this string (23 here), so it shows:
String Length: 23
Thank you very much! hdf5, string length, define MATLAB Answers — New Questions
error in envelope function
The envelope function always gives me an error when I enter the input ‘peaks’, whatever the data may be. The error that appears is this:
Error using findpeaks
Too many input arguments.
Error in envelope>envPeak (line 181)
[~,iPk] = findpeaks(double(x(:,chan)),’MinPeakDistance’,n);
Error in envelope (line 79)
[yupper, ylower] = envPeak(x,n);
I have looked at three different versions of Matlab and it gives me the error in all three.The envelope function always gives me an error when I enter the input ‘peaks’, whatever the data may be. The error that appears is this:
Error using findpeaks
Too many input arguments.
Error in envelope>envPeak (line 181)
[~,iPk] = findpeaks(double(x(:,chan)),’MinPeakDistance’,n);
Error in envelope (line 79)
[yupper, ylower] = envPeak(x,n);
I have looked at three different versions of Matlab and it gives me the error in all three. The envelope function always gives me an error when I enter the input ‘peaks’, whatever the data may be. The error that appears is this:
Error using findpeaks
Too many input arguments.
Error in envelope>envPeak (line 181)
[~,iPk] = findpeaks(double(x(:,chan)),’MinPeakDistance’,n);
Error in envelope (line 79)
[yupper, ylower] = envPeak(x,n);
I have looked at three different versions of Matlab and it gives me the error in all three. envelope signal MATLAB Answers — New Questions
How to generate C++ code from a *.fis file?
How do I generate C++ code from a *.fis file?How do I generate C++ code from a *.fis file? How do I generate C++ code from a *.fis file? code generation MATLAB Answers — New Questions
ASCII characters in code?
I have a little problem with the display of some characters in my matlab code. The header of data i read from a text file contains special characters, which i need to write down into my code. E.g. one column has the Name "T / °C". Now every time i close and reopen Matlab, the parts in my code are displayd like this: "T / �C". So everyday i have to replace all occurances of this character, and of course it is not the only character. Is there a way to solve this. I did not find any setting in the preferences.
Thank you!I have a little problem with the display of some characters in my matlab code. The header of data i read from a text file contains special characters, which i need to write down into my code. E.g. one column has the Name "T / °C". Now every time i close and reopen Matlab, the parts in my code are displayd like this: "T / �C". So everyday i have to replace all occurances of this character, and of course it is not the only character. Is there a way to solve this. I did not find any setting in the preferences.
Thank you! I have a little problem with the display of some characters in my matlab code. The header of data i read from a text file contains special characters, which i need to write down into my code. E.g. one column has the Name "T / °C". Now every time i close and reopen Matlab, the parts in my code are displayd like this: "T / �C". So everyday i have to replace all occurances of this character, and of course it is not the only character. Is there a way to solve this. I did not find any setting in the preferences.
Thank you! ascii character display MATLAB Answers — New Questions
how to generate {8,3} regular graphs for large number of vertices
hyperbolic latticeshyperbolic lattices hyperbolic lattices graph, matrices MATLAB Answers — New Questions
split Each Data store
How we can Split Each data store while training neural network with not disturbing the sequence of Images and labels so that it can train images and corresponding labels accordingly.
Thanks in advance.How we can Split Each data store while training neural network with not disturbing the sequence of Images and labels so that it can train images and corresponding labels accordingly.
Thanks in advance. How we can Split Each data store while training neural network with not disturbing the sequence of Images and labels so that it can train images and corresponding labels accordingly.
Thanks in advance. datastore, split, labels MATLAB Answers — New Questions