Category: Matlab
Category Archives: Matlab
how to import parameters (weights and bias) in simulink
Hello experts,
I have parameters (weights and bias) saved in mat file.
and I use matlab function block in my simulink model to use this parameters.
the problem that the simulink can not read the parameters and give me this error:
How can I solve this issue??Hello experts,
I have parameters (weights and bias) saved in mat file.
and I use matlab function block in my simulink model to use this parameters.
the problem that the simulink can not read the parameters and give me this error:
How can I solve this issue?? Hello experts,
I have parameters (weights and bias) saved in mat file.
and I use matlab function block in my simulink model to use this parameters.
the problem that the simulink can not read the parameters and give me this error:
How can I solve this issue?? simulink, parameters MATLAB Answers — New Questions
How to display geographic gridlines or tickmarks on the current figure and underlay it by a terrain basemap?
I have plottted this map using the following STAMPS command
"ps_plot(‘hgt’)" which plots a map over elevation values for a study area whose boundaries were cropped/predetrmined by numerous processing steps. I eventually would like to display gridlines or tick on intersections over this map in order to be able to export it as png or tiff image so I can manually georeference this map on other softwares.
Additionally, if matlab can plot already georeferenced/geocoded maps, please let me know how to do it!I have plottted this map using the following STAMPS command
"ps_plot(‘hgt’)" which plots a map over elevation values for a study area whose boundaries were cropped/predetrmined by numerous processing steps. I eventually would like to display gridlines or tick on intersections over this map in order to be able to export it as png or tiff image so I can manually georeference this map on other softwares.
Additionally, if matlab can plot already georeferenced/geocoded maps, please let me know how to do it! I have plottted this map using the following STAMPS command
"ps_plot(‘hgt’)" which plots a map over elevation values for a study area whose boundaries were cropped/predetrmined by numerous processing steps. I eventually would like to display gridlines or tick on intersections over this map in order to be able to export it as png or tiff image so I can manually georeference this map on other softwares.
Additionally, if matlab can plot already georeferenced/geocoded maps, please let me know how to do it! image processing, digital image processing, colormap, machine learning MATLAB Answers — New Questions
How can I execute the empirical mode decomposition (emd) syntax in MATLAB R2016b?
Hello, I want to inform you that I am currently using MATLAB version R2016b. Please guide me through executing the empirical mode decomposition (emd) syntax.
Best regards,
NavidHello, I want to inform you that I am currently using MATLAB version R2016b. Please guide me through executing the empirical mode decomposition (emd) syntax.
Best regards,
Navid Hello, I want to inform you that I am currently using MATLAB version R2016b. Please guide me through executing the empirical mode decomposition (emd) syntax.
Best regards,
Navid empirical mode decomposition (emd) MATLAB Answers — New Questions
Field ii ultrasound simulation: Unable to run C compiled binary files (mexw64 extension)
In Field ii ultrasound simulation library a particular function field_init needs to be run initially. Here is the code for the m-file containing a binary complied function Mat_field that Matlab does not seem to recognize:
function res = field_init (suppress)
% Call the C-part of the program to initialize it
if (nargin==1)
Mat_field (5001,suppress);
else
Mat_field (5001,1);
end
Here is what I get when I invoke this function. Matlab does not seem to recognize Mat_field function tho the files Mat_field.mexw64 exists:
field_init
Unrecognized function or variable ‘Mat_field’.
Error in field_init (line 25)
Mat_field (5001,1);In Field ii ultrasound simulation library a particular function field_init needs to be run initially. Here is the code for the m-file containing a binary complied function Mat_field that Matlab does not seem to recognize:
function res = field_init (suppress)
% Call the C-part of the program to initialize it
if (nargin==1)
Mat_field (5001,suppress);
else
Mat_field (5001,1);
end
Here is what I get when I invoke this function. Matlab does not seem to recognize Mat_field function tho the files Mat_field.mexw64 exists:
field_init
Unrecognized function or variable ‘Mat_field’.
Error in field_init (line 25)
Mat_field (5001,1); In Field ii ultrasound simulation library a particular function field_init needs to be run initially. Here is the code for the m-file containing a binary complied function Mat_field that Matlab does not seem to recognize:
function res = field_init (suppress)
% Call the C-part of the program to initialize it
if (nargin==1)
Mat_field (5001,suppress);
else
Mat_field (5001,1);
end
Here is what I get when I invoke this function. Matlab does not seem to recognize Mat_field function tho the files Mat_field.mexw64 exists:
field_init
Unrecognized function or variable ‘Mat_field’.
Error in field_init (line 25)
Mat_field (5001,1); c compiled files mex file MATLAB Answers — New Questions
how convert arraycell to use with writecell
{’31/07/2024′} {[ 0]} {[ 0]} {[ 0]} {[ 0]} {[2486]}
{’01/08/2024′} {[ 0]} {[ 0]} {[ 0]} {[ 0]} {[2496]}
{’02/08/2024′} {[ 0]} {[ 0]} {[ 1]} {[ 0]} {[2405]}
{’03/08/2024′} {[ 0]} {[ 1]} {[ 0]} {[ 0]} {[2486]}
i want write file .txt and convert in :
31/07/2024 0 0 0 0 2486
01/08/2024 0 0 0 0 2496
02/08/2024 0 0 2 0 2405
03/08/2024 0 1 0 0 2486
i try to use writecell(AA,’C:TitancancmyTextFile.txt’);
but i see this:
0,0,0,0,0…{’31/07/2024′} {[ 0]} {[ 0]} {[ 0]} {[ 0]} {[2486]}
{’01/08/2024′} {[ 0]} {[ 0]} {[ 0]} {[ 0]} {[2496]}
{’02/08/2024′} {[ 0]} {[ 0]} {[ 1]} {[ 0]} {[2405]}
{’03/08/2024′} {[ 0]} {[ 1]} {[ 0]} {[ 0]} {[2486]}
i want write file .txt and convert in :
31/07/2024 0 0 0 0 2486
01/08/2024 0 0 0 0 2496
02/08/2024 0 0 2 0 2405
03/08/2024 0 1 0 0 2486
i try to use writecell(AA,’C:TitancancmyTextFile.txt’);
but i see this:
0,0,0,0,0… {’31/07/2024′} {[ 0]} {[ 0]} {[ 0]} {[ 0]} {[2486]}
{’01/08/2024′} {[ 0]} {[ 0]} {[ 0]} {[ 0]} {[2496]}
{’02/08/2024′} {[ 0]} {[ 0]} {[ 1]} {[ 0]} {[2405]}
{’03/08/2024′} {[ 0]} {[ 1]} {[ 0]} {[ 0]} {[2486]}
i want write file .txt and convert in :
31/07/2024 0 0 0 0 2486
01/08/2024 0 0 0 0 2496
02/08/2024 0 0 2 0 2405
03/08/2024 0 1 0 0 2486
i try to use writecell(AA,’C:TitancancmyTextFile.txt’);
but i see this:
0,0,0,0,0… how convert arraycell to use with writecell MATLAB Answers — New Questions
How to use the class of Interleaved ADC.m?
Why the input signal “analog” should be a scalar? Coud Matlab give an example of m-file scripts to demonstrate its usage?Why the input signal “analog” should be a scalar? Coud Matlab give an example of m-file scripts to demonstrate its usage? Why the input signal “analog” should be a scalar? Coud Matlab give an example of m-file scripts to demonstrate its usage? interleaved adc MATLAB Answers — New Questions
The frequency response between the components obtained from wavelet decomposition and the original signal
Why does the fft of the component corresponding to the last approximation coefficient obtained after wavelet decomposition not match the fft of the original signal in the low-frequency region, resulting in an unsmooth frequency response between the two and varying with the original signal. Is using FFT to solve frequency response unreliable?
clearvars;close all;clc;
fs=10;
dt=1/fs;
t=dt:dt:200;
N=length(t);
signal=(0.2)*randn(1,N);
Max_level=wmaxlev(length(signal),’db10′);
[C,L]=wavedec(signal,Max_level,’fk8′);
level=6;
xL_DWT = wrcoef(‘a’,C,L,’fk8′,level);
xH_DWT=signal-xL_DWT;
%fft
Nfft=length(t);
f_DWT = (1:Nfft/2)*fs/(Nfft);
xL_DWT_fft=fftshift(fft(xL_DWT,Nfft));
xH_DWT_fft=fftshift(fft(xH_DWT,Nfft));
signal_fft=fftshift(fft(signal,Nfft));
wn_low_DWT=xL_DWT_fft./signal_fft;
wn_high_DWT=1-wn_low_DWT;
figure
plot(f_DWT,wn_low_DWT(Nfft/2+1:end));
hold on
plot(f_DWT,wn_high_DWT(Nfft/2+1:end));
ylim([-0.5 2]);
yticks([-0.5:0.5:2])
xlim([0 fs/2^(level-1)]);
xticks([0 fs/2^(level+1) fs/2^(level) fs/2^(level-1)])
xticklabels({‘0′,’fs/2^{i+1}’,’fs/2^{i}’,’fs/2^{i-1}’})Why does the fft of the component corresponding to the last approximation coefficient obtained after wavelet decomposition not match the fft of the original signal in the low-frequency region, resulting in an unsmooth frequency response between the two and varying with the original signal. Is using FFT to solve frequency response unreliable?
clearvars;close all;clc;
fs=10;
dt=1/fs;
t=dt:dt:200;
N=length(t);
signal=(0.2)*randn(1,N);
Max_level=wmaxlev(length(signal),’db10′);
[C,L]=wavedec(signal,Max_level,’fk8′);
level=6;
xL_DWT = wrcoef(‘a’,C,L,’fk8′,level);
xH_DWT=signal-xL_DWT;
%fft
Nfft=length(t);
f_DWT = (1:Nfft/2)*fs/(Nfft);
xL_DWT_fft=fftshift(fft(xL_DWT,Nfft));
xH_DWT_fft=fftshift(fft(xH_DWT,Nfft));
signal_fft=fftshift(fft(signal,Nfft));
wn_low_DWT=xL_DWT_fft./signal_fft;
wn_high_DWT=1-wn_low_DWT;
figure
plot(f_DWT,wn_low_DWT(Nfft/2+1:end));
hold on
plot(f_DWT,wn_high_DWT(Nfft/2+1:end));
ylim([-0.5 2]);
yticks([-0.5:0.5:2])
xlim([0 fs/2^(level-1)]);
xticks([0 fs/2^(level+1) fs/2^(level) fs/2^(level-1)])
xticklabels({‘0′,’fs/2^{i+1}’,’fs/2^{i}’,’fs/2^{i-1}’}) Why does the fft of the component corresponding to the last approximation coefficient obtained after wavelet decomposition not match the fft of the original signal in the low-frequency region, resulting in an unsmooth frequency response between the two and varying with the original signal. Is using FFT to solve frequency response unreliable?
clearvars;close all;clc;
fs=10;
dt=1/fs;
t=dt:dt:200;
N=length(t);
signal=(0.2)*randn(1,N);
Max_level=wmaxlev(length(signal),’db10′);
[C,L]=wavedec(signal,Max_level,’fk8′);
level=6;
xL_DWT = wrcoef(‘a’,C,L,’fk8′,level);
xH_DWT=signal-xL_DWT;
%fft
Nfft=length(t);
f_DWT = (1:Nfft/2)*fs/(Nfft);
xL_DWT_fft=fftshift(fft(xL_DWT,Nfft));
xH_DWT_fft=fftshift(fft(xH_DWT,Nfft));
signal_fft=fftshift(fft(signal,Nfft));
wn_low_DWT=xL_DWT_fft./signal_fft;
wn_high_DWT=1-wn_low_DWT;
figure
plot(f_DWT,wn_low_DWT(Nfft/2+1:end));
hold on
plot(f_DWT,wn_high_DWT(Nfft/2+1:end));
ylim([-0.5 2]);
yticks([-0.5:0.5:2])
xlim([0 fs/2^(level-1)]);
xticks([0 fs/2^(level+1) fs/2^(level) fs/2^(level-1)])
xticklabels({‘0′,’fs/2^{i+1}’,’fs/2^{i}’,’fs/2^{i-1}’}) fft, wavelet, frequency response, decomposition MATLAB Answers — New Questions
How can I manipulate the 2D data to make it smoother
I have the following data represented by the surface plot:
clear; clc;
load(‘data.mat’)
figure;
surf(nXX,nYY,nZZ,’linestyle’,’none’,’facecolor’,’interp’)
hold on
plot3([0, 0.5], [0, 0.145], [2, 2],’Color’,’white’,’LineStyle’,’–‘,’LineWidth’,2);
plot3([0, 0.5], [2*0.145, 0.145], [2, 2],’Color’,’black’,’LineStyle’,’–‘,’LineWidth’,2);
annotation(‘ellipse’,[0.08 0.58 0.18 0.34],’LineWidth’,2);
xlabel(‘C_a’)
ylabel(‘C_d’)
zlabel(‘C_z’)
view(2)
colorbar
set(gca,’FontSize’,13)
I want to remove the blue part inside the ellipse and extend the yellow area smoothly till C_a=0 and above the black dashed line. Although the yellow region appears constant, it actually changes very slowly. I aim to extend this yellow part while preserving its gradual variation.I have the following data represented by the surface plot:
clear; clc;
load(‘data.mat’)
figure;
surf(nXX,nYY,nZZ,’linestyle’,’none’,’facecolor’,’interp’)
hold on
plot3([0, 0.5], [0, 0.145], [2, 2],’Color’,’white’,’LineStyle’,’–‘,’LineWidth’,2);
plot3([0, 0.5], [2*0.145, 0.145], [2, 2],’Color’,’black’,’LineStyle’,’–‘,’LineWidth’,2);
annotation(‘ellipse’,[0.08 0.58 0.18 0.34],’LineWidth’,2);
xlabel(‘C_a’)
ylabel(‘C_d’)
zlabel(‘C_z’)
view(2)
colorbar
set(gca,’FontSize’,13)
I want to remove the blue part inside the ellipse and extend the yellow area smoothly till C_a=0 and above the black dashed line. Although the yellow region appears constant, it actually changes very slowly. I aim to extend this yellow part while preserving its gradual variation. I have the following data represented by the surface plot:
clear; clc;
load(‘data.mat’)
figure;
surf(nXX,nYY,nZZ,’linestyle’,’none’,’facecolor’,’interp’)
hold on
plot3([0, 0.5], [0, 0.145], [2, 2],’Color’,’white’,’LineStyle’,’–‘,’LineWidth’,2);
plot3([0, 0.5], [2*0.145, 0.145], [2, 2],’Color’,’black’,’LineStyle’,’–‘,’LineWidth’,2);
annotation(‘ellipse’,[0.08 0.58 0.18 0.34],’LineWidth’,2);
xlabel(‘C_a’)
ylabel(‘C_d’)
zlabel(‘C_z’)
view(2)
colorbar
set(gca,’FontSize’,13)
I want to remove the blue part inside the ellipse and extend the yellow area smoothly till C_a=0 and above the black dashed line. Although the yellow region appears constant, it actually changes very slowly. I aim to extend this yellow part while preserving its gradual variation. interpolation, fitting MATLAB Answers — New Questions
Find the turing pattern for following equation
the equation is
dx/dt={r/(1-ky) – r0-r1x-[alpha*(1-beta*y)*x]/[a+(1-beta*y)*x]}x
dy/dt={[new-cy/[a+(1-beta*y)*x]}*ythe equation is
dx/dt={r/(1-ky) – r0-r1x-[alpha*(1-beta*y)*x]/[a+(1-beta*y)*x]}x
dy/dt={[new-cy/[a+(1-beta*y)*x]}*y the equation is
dx/dt={r/(1-ky) – r0-r1x-[alpha*(1-beta*y)*x]/[a+(1-beta*y)*x]}x
dy/dt={[new-cy/[a+(1-beta*y)*x]}*y turing MATLAB Answers — New Questions
I have been working on 3D imaging in the form of pixels with spheres in a box and need help in finding out the contact points in between the spheres in the produced pixel data
I have tried finding the exact point by 1st extracting the 2 object from data set of 161*161*105 unit8 in volumesegmenter and then used edge command to observe onle the boundary.I want to know how can I exactract exact contact point between 2 spheres by searching in 105 slices and without using the voxel command to get the co-ordinates.
Here is my code:
%% joining bd1,bd2,bd3,bd4
A=cat(3,Bd1, Bd2,Bd3,Bd4);
B=cat(3,L1,L2,L3,L4);
%% for extracting 2 spheres
T=table(A,B);
P=(T.B=="sphere8");
Q=(T.B=="sphere7");
R=P+Q;
%% visualization of 2 joined spheres
volumeSegmenter(R)
%% making the only edge visible for inspection
SS=edge3(R,"approxcanny",0.5);
SS1=im2double(SS);
volumeSegmenter(SS1)I have tried finding the exact point by 1st extracting the 2 object from data set of 161*161*105 unit8 in volumesegmenter and then used edge command to observe onle the boundary.I want to know how can I exactract exact contact point between 2 spheres by searching in 105 slices and without using the voxel command to get the co-ordinates.
Here is my code:
%% joining bd1,bd2,bd3,bd4
A=cat(3,Bd1, Bd2,Bd3,Bd4);
B=cat(3,L1,L2,L3,L4);
%% for extracting 2 spheres
T=table(A,B);
P=(T.B=="sphere8");
Q=(T.B=="sphere7");
R=P+Q;
%% visualization of 2 joined spheres
volumeSegmenter(R)
%% making the only edge visible for inspection
SS=edge3(R,"approxcanny",0.5);
SS1=im2double(SS);
volumeSegmenter(SS1) I have tried finding the exact point by 1st extracting the 2 object from data set of 161*161*105 unit8 in volumesegmenter and then used edge command to observe onle the boundary.I want to know how can I exactract exact contact point between 2 spheres by searching in 105 slices and without using the voxel command to get the co-ordinates.
Here is my code:
%% joining bd1,bd2,bd3,bd4
A=cat(3,Bd1, Bd2,Bd3,Bd4);
B=cat(3,L1,L2,L3,L4);
%% for extracting 2 spheres
T=table(A,B);
P=(T.B=="sphere8");
Q=(T.B=="sphere7");
R=P+Q;
%% visualization of 2 joined spheres
volumeSegmenter(R)
%% making the only edge visible for inspection
SS=edge3(R,"approxcanny",0.5);
SS1=im2double(SS);
volumeSegmenter(SS1) matlab, image processing, 3d image processing, contact points MATLAB Answers — New Questions
tomographic wifi sensing using wifi adapters
hello i would like to ask how to modify the following programs to use wifi adapters rather than sdr to perform tomographic wifi sensing. thanks very much.
https://www.mathworks.com/help/wlan/ug/detect-human-presence-using-wireless-sensing-with-deep-learning.html
https://www.mathworks.com/matlabcentral/fileexchange/43008-2-d-tomographic-reconstruction-demohello i would like to ask how to modify the following programs to use wifi adapters rather than sdr to perform tomographic wifi sensing. thanks very much.
https://www.mathworks.com/help/wlan/ug/detect-human-presence-using-wireless-sensing-with-deep-learning.html
https://www.mathworks.com/matlabcentral/fileexchange/43008-2-d-tomographic-reconstruction-demo hello i would like to ask how to modify the following programs to use wifi adapters rather than sdr to perform tomographic wifi sensing. thanks very much.
https://www.mathworks.com/help/wlan/ug/detect-human-presence-using-wireless-sensing-with-deep-learning.html
https://www.mathworks.com/matlabcentral/fileexchange/43008-2-d-tomographic-reconstruction-demo tomographic, wifi, sensing MATLAB Answers — New Questions
Empty spherical plot – strange error
I find it strange that I get an empty plot with the give command, and get the given error:
Error using matlab.graphics.chart.primitive.Surface
Value must be a vector or 2D array of numeric type.
Error in surf (line 145)
hh = matlab.graphics.chart.primitive.Surface(allargs{:});
Error in polar_coord_soln_Manz (line 59)
surf(X, Y, Z, Psi);
% Constants
hbar = 1.0545718e-34;
m = 9.10938356e-31;
E_ion = 5.139 * 1.60218e-19;
k_f = 2 * m * E_ion / hbar^2;
% Define alpha (renamed to avoid conflict with MATLAB function)
alpha_val = sqrt(k_f);
% Radial wave function
function R = radial_wavefunction(r, n, l, alpha)
L = laguerreL(n-l-1, 2*l+1, alpha * r.^2);
R = sqrt((2 * alpha)^(l+1) / factorial(n-l-1)) .* exp(-alpha * r.^2) .* (alpha * r).^l .* L;
end
% Spherical harmonic (assuming it’s defined elsewhere)
function Y = spherical_harmonic(theta, phi, l, m)
Y = legendre(l, cos(theta)) .* exp(1i * m * phi);
end
% Total wave function in spherical coordinates
function psi = spherical_wavefunction(r, theta, phi, n, l, m, alpha)
R = radial_wavefunction(r, n, l, alpha);
Y = spherical_harmonic(theta, phi, l, m);
psi = R .* Y;
end
% Define grid
r = linspace(0, 10, 50); % Radial coordinate r
theta = linspace(0, pi, 50); % Polar angle theta
phi = linspace(0, 2*pi, 50); % Azimuthal angle phi
% Create grid for 3D plotting
[R, Theta, Phi] = meshgrid(r, theta, phi);
n = 1;
l = 0;
m = 0;
Psi = zeros(size(R));
for i = 1:numel(R)
Psi(i) = abs(spherical_wavefunction(R(i), Theta(i), Phi(i), n, l, m, alpha_val))^2; % Taking absolute value and squaring
end
% Reshape Psi to be 2D
Psi = reshape(Psi, size(R));
% Spherical to Cartesian Conversion
X = R .* sin(Theta) .* cos(Phi);
Y = R .* sin(Theta) .* sin(Phi);
Z = R .* cos(Theta);
% Plotting 3D surface
figure;
surf(X, Y, Z, Psi);
xlabel(‘x’);
ylabel(‘y’);
zlabel(‘z’);
title([‘|psi_{‘, num2str(n), ‘,’, num2str(l), ‘,’, num2str(m), ‘}(r, theta, phi)|^2 for Sodium’]);
colorbar;
axis equal;I find it strange that I get an empty plot with the give command, and get the given error:
Error using matlab.graphics.chart.primitive.Surface
Value must be a vector or 2D array of numeric type.
Error in surf (line 145)
hh = matlab.graphics.chart.primitive.Surface(allargs{:});
Error in polar_coord_soln_Manz (line 59)
surf(X, Y, Z, Psi);
% Constants
hbar = 1.0545718e-34;
m = 9.10938356e-31;
E_ion = 5.139 * 1.60218e-19;
k_f = 2 * m * E_ion / hbar^2;
% Define alpha (renamed to avoid conflict with MATLAB function)
alpha_val = sqrt(k_f);
% Radial wave function
function R = radial_wavefunction(r, n, l, alpha)
L = laguerreL(n-l-1, 2*l+1, alpha * r.^2);
R = sqrt((2 * alpha)^(l+1) / factorial(n-l-1)) .* exp(-alpha * r.^2) .* (alpha * r).^l .* L;
end
% Spherical harmonic (assuming it’s defined elsewhere)
function Y = spherical_harmonic(theta, phi, l, m)
Y = legendre(l, cos(theta)) .* exp(1i * m * phi);
end
% Total wave function in spherical coordinates
function psi = spherical_wavefunction(r, theta, phi, n, l, m, alpha)
R = radial_wavefunction(r, n, l, alpha);
Y = spherical_harmonic(theta, phi, l, m);
psi = R .* Y;
end
% Define grid
r = linspace(0, 10, 50); % Radial coordinate r
theta = linspace(0, pi, 50); % Polar angle theta
phi = linspace(0, 2*pi, 50); % Azimuthal angle phi
% Create grid for 3D plotting
[R, Theta, Phi] = meshgrid(r, theta, phi);
n = 1;
l = 0;
m = 0;
Psi = zeros(size(R));
for i = 1:numel(R)
Psi(i) = abs(spherical_wavefunction(R(i), Theta(i), Phi(i), n, l, m, alpha_val))^2; % Taking absolute value and squaring
end
% Reshape Psi to be 2D
Psi = reshape(Psi, size(R));
% Spherical to Cartesian Conversion
X = R .* sin(Theta) .* cos(Phi);
Y = R .* sin(Theta) .* sin(Phi);
Z = R .* cos(Theta);
% Plotting 3D surface
figure;
surf(X, Y, Z, Psi);
xlabel(‘x’);
ylabel(‘y’);
zlabel(‘z’);
title([‘|psi_{‘, num2str(n), ‘,’, num2str(l), ‘,’, num2str(m), ‘}(r, theta, phi)|^2 for Sodium’]);
colorbar;
axis equal; I find it strange that I get an empty plot with the give command, and get the given error:
Error using matlab.graphics.chart.primitive.Surface
Value must be a vector or 2D array of numeric type.
Error in surf (line 145)
hh = matlab.graphics.chart.primitive.Surface(allargs{:});
Error in polar_coord_soln_Manz (line 59)
surf(X, Y, Z, Psi);
% Constants
hbar = 1.0545718e-34;
m = 9.10938356e-31;
E_ion = 5.139 * 1.60218e-19;
k_f = 2 * m * E_ion / hbar^2;
% Define alpha (renamed to avoid conflict with MATLAB function)
alpha_val = sqrt(k_f);
% Radial wave function
function R = radial_wavefunction(r, n, l, alpha)
L = laguerreL(n-l-1, 2*l+1, alpha * r.^2);
R = sqrt((2 * alpha)^(l+1) / factorial(n-l-1)) .* exp(-alpha * r.^2) .* (alpha * r).^l .* L;
end
% Spherical harmonic (assuming it’s defined elsewhere)
function Y = spherical_harmonic(theta, phi, l, m)
Y = legendre(l, cos(theta)) .* exp(1i * m * phi);
end
% Total wave function in spherical coordinates
function psi = spherical_wavefunction(r, theta, phi, n, l, m, alpha)
R = radial_wavefunction(r, n, l, alpha);
Y = spherical_harmonic(theta, phi, l, m);
psi = R .* Y;
end
% Define grid
r = linspace(0, 10, 50); % Radial coordinate r
theta = linspace(0, pi, 50); % Polar angle theta
phi = linspace(0, 2*pi, 50); % Azimuthal angle phi
% Create grid for 3D plotting
[R, Theta, Phi] = meshgrid(r, theta, phi);
n = 1;
l = 0;
m = 0;
Psi = zeros(size(R));
for i = 1:numel(R)
Psi(i) = abs(spherical_wavefunction(R(i), Theta(i), Phi(i), n, l, m, alpha_val))^2; % Taking absolute value and squaring
end
% Reshape Psi to be 2D
Psi = reshape(Psi, size(R));
% Spherical to Cartesian Conversion
X = R .* sin(Theta) .* cos(Phi);
Y = R .* sin(Theta) .* sin(Phi);
Z = R .* cos(Theta);
% Plotting 3D surface
figure;
surf(X, Y, Z, Psi);
xlabel(‘x’);
ylabel(‘y’);
zlabel(‘z’);
title([‘|psi_{‘, num2str(n), ‘,’, num2str(l), ‘,’, num2str(m), ‘}(r, theta, phi)|^2 for Sodium’]);
colorbar;
axis equal; 3d plots, spherical MATLAB Answers — New Questions
Motion Planning using Frenet Reference Path
Can you please provide about how can I run my customized road scenario using Frenet Reference Path. Because, I’m taking reference of the example by using your exmples in the Object Detection and Motion Planning, however I’m not able to find the right waypoint for my customized Ego Vehicle. Herewith, I’ve attached my waypoint Screen shot and reference link from your website.Can you please provide about how can I run my customized road scenario using Frenet Reference Path. Because, I’m taking reference of the example by using your exmples in the Object Detection and Motion Planning, however I’m not able to find the right waypoint for my customized Ego Vehicle. Herewith, I’ve attached my waypoint Screen shot and reference link from your website. Can you please provide about how can I run my customized road scenario using Frenet Reference Path. Because, I’m taking reference of the example by using your exmples in the Object Detection and Motion Planning, however I’m not able to find the right waypoint for my customized Ego Vehicle. Herewith, I’ve attached my waypoint Screen shot and reference link from your website. frenetreferencepath, roadscenario MATLAB Answers — New Questions
bug parfor: analyzing and transferring files to worker: not done: blocked
Hello there,
I am a running a working script with parfor on matlab, after a while (~1200 iteration on parfor), matlab block without appareant reasons while producing the following message: "analyzing and transferring files to workers…". I am running the parfor on matlab 2023a, on local parfor only. I did validate the cluster of parfor before. The code is working correctly as the 1200 files were done. I tried with other very similar files and it did block also similarly. There is largely enough memory space on my PC. I tried to restart matlab, and also my PC, but this did not solve the problem. I also tried to find solution online, unsuccesfully. Anyone would have an idea ? many thanks for your attention.Hello there,
I am a running a working script with parfor on matlab, after a while (~1200 iteration on parfor), matlab block without appareant reasons while producing the following message: "analyzing and transferring files to workers…". I am running the parfor on matlab 2023a, on local parfor only. I did validate the cluster of parfor before. The code is working correctly as the 1200 files were done. I tried with other very similar files and it did block also similarly. There is largely enough memory space on my PC. I tried to restart matlab, and also my PC, but this did not solve the problem. I also tried to find solution online, unsuccesfully. Anyone would have an idea ? many thanks for your attention. Hello there,
I am a running a working script with parfor on matlab, after a while (~1200 iteration on parfor), matlab block without appareant reasons while producing the following message: "analyzing and transferring files to workers…". I am running the parfor on matlab 2023a, on local parfor only. I did validate the cluster of parfor before. The code is working correctly as the 1200 files were done. I tried with other very similar files and it did block also similarly. There is largely enough memory space on my PC. I tried to restart matlab, and also my PC, but this did not solve the problem. I also tried to find solution online, unsuccesfully. Anyone would have an idea ? many thanks for your attention. parfor, transferring, workers MATLAB Answers — New Questions
Will the usage of college email while registering in Mini Drone Competition 2024 create conflict as the college email is already having a educational access?
Recently my team had came across Minidrone Competition and we have decided to try it out.While going through the guidelines ,I understood that we will be given special access to MATLAB and SIMULINK tools to use in competition.But would it cause any conflicts/error if the email registered had another license(In this case an educational license) in it or should I use a new email without any access?
disp("ThanksInAdvance");Recently my team had came across Minidrone Competition and we have decided to try it out.While going through the guidelines ,I understood that we will be given special access to MATLAB and SIMULINK tools to use in competition.But would it cause any conflicts/error if the email registered had another license(In this case an educational license) in it or should I use a new email without any access?
disp("ThanksInAdvance"); Recently my team had came across Minidrone Competition and we have decided to try it out.While going through the guidelines ,I understood that we will be given special access to MATLAB and SIMULINK tools to use in competition.But would it cause any conflicts/error if the email registered had another license(In this case an educational license) in it or should I use a new email without any access?
disp("ThanksInAdvance"); minidrone competition MATLAB Answers — New Questions
unable to get reference output for synchronous reluctance motor
Unable to get control output for synchronous reluctance motor and kindly give input for how to connect current controller for the motorUnable to get control output for synchronous reluctance motor and kindly give input for how to connect current controller for the motor Unable to get control output for synchronous reluctance motor and kindly give input for how to connect current controller for the motor synchronous reluctance motor, controller MATLAB Answers — New Questions
Best method to simulate a lead-acid battery to later be used in an MPC Controller
Hi,
Quick question to the experts, I need to estimate/simulate the SOC of a stack of lead-acid batteries, this SOC function will later be used in an MPC controller. I have seen several ways to simulate batteries, however I am still not sure which one is the most suitable in my case:
Simscape Battery
Lead-Acid Battery library ( https://la.mathworks.com/help/simscape/ug/lead-acid-battery.html )
Simscape Electrical – Specialized Power Systems – Sources ( https://la.mathworks.com/help/sps/powersys/ref/battery.html )
Additionally, if the right one is the "Lead-Acid Battery library", how can you connect the cells in series? its a newbie question that I have been trying to solve but I couldnt, I only got it working in parallel but not in parallel.
Many thanks!!
RaulHi,
Quick question to the experts, I need to estimate/simulate the SOC of a stack of lead-acid batteries, this SOC function will later be used in an MPC controller. I have seen several ways to simulate batteries, however I am still not sure which one is the most suitable in my case:
Simscape Battery
Lead-Acid Battery library ( https://la.mathworks.com/help/simscape/ug/lead-acid-battery.html )
Simscape Electrical – Specialized Power Systems – Sources ( https://la.mathworks.com/help/sps/powersys/ref/battery.html )
Additionally, if the right one is the "Lead-Acid Battery library", how can you connect the cells in series? its a newbie question that I have been trying to solve but I couldnt, I only got it working in parallel but not in parallel.
Many thanks!!
Raul Hi,
Quick question to the experts, I need to estimate/simulate the SOC of a stack of lead-acid batteries, this SOC function will later be used in an MPC controller. I have seen several ways to simulate batteries, however I am still not sure which one is the most suitable in my case:
Simscape Battery
Lead-Acid Battery library ( https://la.mathworks.com/help/simscape/ug/lead-acid-battery.html )
Simscape Electrical – Specialized Power Systems – Sources ( https://la.mathworks.com/help/sps/powersys/ref/battery.html )
Additionally, if the right one is the "Lead-Acid Battery library", how can you connect the cells in series? its a newbie question that I have been trying to solve but I couldnt, I only got it working in parallel but not in parallel.
Many thanks!!
Raul battery_system_management, mpc MATLAB Answers — New Questions
Simulink logging intervals with discrete and continuous blocks
Hi all,
In my Simulink Model are some Discrete Blocks (implemented as Level-2 Matlab S-Function) with period time T and also some continuous blocks.
Is it possible to log the output only when the discrete blocks change their output?
Thanks in advance, I really appreciate your answer.Hi all,
In my Simulink Model are some Discrete Blocks (implemented as Level-2 Matlab S-Function) with period time T and also some continuous blocks.
Is it possible to log the output only when the discrete blocks change their output?
Thanks in advance, I really appreciate your answer. Hi all,
In my Simulink Model are some Discrete Blocks (implemented as Level-2 Matlab S-Function) with period time T and also some continuous blocks.
Is it possible to log the output only when the discrete blocks change their output?
Thanks in advance, I really appreciate your answer. simulink, logging MATLAB Answers — New Questions
Add costume buttons to imagesc plot
Hello,
I wish to be able to run operation on an image from the image display. For example: I am presenting a binary image using imagesc, and I want to be able to reshape the data from the display GUI (with additional zero padding if needed). Another example: I want to have "two channels" to the dispaly, an image and a "mask", and I want to be able to present the mask over the image and remove it using a button in the display. Finally, I want to "wrap" all this as a function to which I will give the data ("image" and "mask" data), and that upon calling will generate this gui with the options I mentioned. What will be a good way to approach this?Hello,
I wish to be able to run operation on an image from the image display. For example: I am presenting a binary image using imagesc, and I want to be able to reshape the data from the display GUI (with additional zero padding if needed). Another example: I want to have "two channels" to the dispaly, an image and a "mask", and I want to be able to present the mask over the image and remove it using a button in the display. Finally, I want to "wrap" all this as a function to which I will give the data ("image" and "mask" data), and that upon calling will generate this gui with the options I mentioned. What will be a good way to approach this? Hello,
I wish to be able to run operation on an image from the image display. For example: I am presenting a binary image using imagesc, and I want to be able to reshape the data from the display GUI (with additional zero padding if needed). Another example: I want to have "two channels" to the dispaly, an image and a "mask", and I want to be able to present the mask over the image and remove it using a button in the display. Finally, I want to "wrap" all this as a function to which I will give the data ("image" and "mask" data), and that upon calling will generate this gui with the options I mentioned. What will be a good way to approach this? image processing, gui MATLAB Answers — New Questions
convert 16 bit image to 8 bit image
how to convert 16 bit image to 8 bit imagehow to convert 16 bit image to 8 bit image how to convert 16 bit image to 8 bit image image processing, matlab r2010a MATLAB Answers — New Questions