Tag Archives: matlab
Why the drone is drifting in HIL?
I am running the
PX4 Autopilot in Hardware-in-the-Loop (HITL) Simulation with UAV Dynamics in Simulink
example,after the set-ups, I run the UAV_Dynamics_Autopilot_Communication model, the flying which should follow the waypoint is not act as I expected in QGC:
there are some warnings on the top and the drone was drifting after following the trajectory.
and a module called 6DOF Rigid body dynamics is in red:
except this two wierd things happen, everthing were fine. No Warning information from Simulink.
I am not sure the fact that 6DOF Rigid body dynamics is red is relative to the drifting, but they show up together makes me curious.
How can I fix the drifting? Why the module is in red?
Thanks for your answer.I am running the
PX4 Autopilot in Hardware-in-the-Loop (HITL) Simulation with UAV Dynamics in Simulink
example,after the set-ups, I run the UAV_Dynamics_Autopilot_Communication model, the flying which should follow the waypoint is not act as I expected in QGC:
there are some warnings on the top and the drone was drifting after following the trajectory.
and a module called 6DOF Rigid body dynamics is in red:
except this two wierd things happen, everthing were fine. No Warning information from Simulink.
I am not sure the fact that 6DOF Rigid body dynamics is red is relative to the drifting, but they show up together makes me curious.
How can I fix the drifting? Why the module is in red?
Thanks for your answer. I am running the
PX4 Autopilot in Hardware-in-the-Loop (HITL) Simulation with UAV Dynamics in Simulink
example,after the set-ups, I run the UAV_Dynamics_Autopilot_Communication model, the flying which should follow the waypoint is not act as I expected in QGC:
there are some warnings on the top and the drone was drifting after following the trajectory.
and a module called 6DOF Rigid body dynamics is in red:
except this two wierd things happen, everthing were fine. No Warning information from Simulink.
I am not sure the fact that 6DOF Rigid body dynamics is red is relative to the drifting, but they show up together makes me curious.
How can I fix the drifting? Why the module is in red?
Thanks for your answer. hil, qgc, simulink MATLAB Answers — New Questions
Writing a code to determine the gradient change in a profile
Hi,
I’m trying to write a code which can determine the gradient change in a given profile. However the code is unable to determine the same correctly and giving incorrect results. For the pic1 below it should give me the width of the region where it is a steep gradient determined.
However for pic2 below it shouldn’t as there is no steep gradient compared to pic1
The code is as below:
clear width;
global width;
global data;
for i=1:max(length(data.variable.t))
for j=1:max(length(data.variable.x))-1
change_p = (abs(data.variable.gradpressure(i,j+1))-abs(data.variable.gradpressure(i,j)))/abs(data.variable.gradpressure(i,j));
%disp(change_p)
if change_p > 0.1
disp("steep gradient found")
width(j)=1-data.variable.x(j);
disp(width)
else
disp("no steep gradient found")
end
end
end
the data.variable.gradpressure is a 1000×100 matrix with t along the vertical and x along the horizontal.
with regards,
rcHi,
I’m trying to write a code which can determine the gradient change in a given profile. However the code is unable to determine the same correctly and giving incorrect results. For the pic1 below it should give me the width of the region where it is a steep gradient determined.
However for pic2 below it shouldn’t as there is no steep gradient compared to pic1
The code is as below:
clear width;
global width;
global data;
for i=1:max(length(data.variable.t))
for j=1:max(length(data.variable.x))-1
change_p = (abs(data.variable.gradpressure(i,j+1))-abs(data.variable.gradpressure(i,j)))/abs(data.variable.gradpressure(i,j));
%disp(change_p)
if change_p > 0.1
disp("steep gradient found")
width(j)=1-data.variable.x(j);
disp(width)
else
disp("no steep gradient found")
end
end
end
the data.variable.gradpressure is a 1000×100 matrix with t along the vertical and x along the horizontal.
with regards,
rc Hi,
I’m trying to write a code which can determine the gradient change in a given profile. However the code is unable to determine the same correctly and giving incorrect results. For the pic1 below it should give me the width of the region where it is a steep gradient determined.
However for pic2 below it shouldn’t as there is no steep gradient compared to pic1
The code is as below:
clear width;
global width;
global data;
for i=1:max(length(data.variable.t))
for j=1:max(length(data.variable.x))-1
change_p = (abs(data.variable.gradpressure(i,j+1))-abs(data.variable.gradpressure(i,j)))/abs(data.variable.gradpressure(i,j));
%disp(change_p)
if change_p > 0.1
disp("steep gradient found")
width(j)=1-data.variable.x(j);
disp(width)
else
disp("no steep gradient found")
end
end
end
the data.variable.gradpressure is a 1000×100 matrix with t along the vertical and x along the horizontal.
with regards,
rc gradient MATLAB Answers — New Questions
Question about combining surf and plot3
Hello all,
I would like to plot a 3D plot in which I plot some scattered 3D points and at the same time I would like to plot surfaces which correspond to the limits of the ranges of my three variables. I attach a .dat file which contains the variables, the variable ‘parameters’ contain the 3D data which to be plotted, they are 500 data points for each of the three variables. The variables p1, p2 and p3 contain the ranges of my three variables, I would like to plot the surfaces which correspond to the limits of these variables, for example for the third variable, this will do the job for the lower limit:
surf(p3(1)*ones(size(parameters,2),size(parameters,2)),’FaceColor’,’r’,’FaceAlpha’,0.3,’EdgeColor’,’none’)
I have a problem which is that after I use the command plot3 to plot the data as follows:
figure(‘units’,’normalized’,’outerposition’,[0 0 1 1])
surf(p3(1)*ones(size(parameters,2),size(parameters,2)),’FaceColor’,’r’,’FaceAlpha’,0.3,’EdgeColor’,’none’)
hold on
plot3(parameters(1,:),parameters(2,:),parameters(3,:),’*r’,’MarkerSize’,15)
hold on
plot3(parameters(1,IDEIM_mu),parameters(2,IDEIM_mu),parameters(3,IDEIM_mu),’ko’,’MarkerSize’,20)
xlim([0.8*p1(1) 1.2*p1(2)]);
ylim([0.8*p2(1) 1.2*p2(2)]);
zlim([0.8*p3(1) 1.2*p3(2)]);
Then the first surface plot disappers. Could you please let me know how I could combine the two kind of plots ? Thanks.Hello all,
I would like to plot a 3D plot in which I plot some scattered 3D points and at the same time I would like to plot surfaces which correspond to the limits of the ranges of my three variables. I attach a .dat file which contains the variables, the variable ‘parameters’ contain the 3D data which to be plotted, they are 500 data points for each of the three variables. The variables p1, p2 and p3 contain the ranges of my three variables, I would like to plot the surfaces which correspond to the limits of these variables, for example for the third variable, this will do the job for the lower limit:
surf(p3(1)*ones(size(parameters,2),size(parameters,2)),’FaceColor’,’r’,’FaceAlpha’,0.3,’EdgeColor’,’none’)
I have a problem which is that after I use the command plot3 to plot the data as follows:
figure(‘units’,’normalized’,’outerposition’,[0 0 1 1])
surf(p3(1)*ones(size(parameters,2),size(parameters,2)),’FaceColor’,’r’,’FaceAlpha’,0.3,’EdgeColor’,’none’)
hold on
plot3(parameters(1,:),parameters(2,:),parameters(3,:),’*r’,’MarkerSize’,15)
hold on
plot3(parameters(1,IDEIM_mu),parameters(2,IDEIM_mu),parameters(3,IDEIM_mu),’ko’,’MarkerSize’,20)
xlim([0.8*p1(1) 1.2*p1(2)]);
ylim([0.8*p2(1) 1.2*p2(2)]);
zlim([0.8*p3(1) 1.2*p3(2)]);
Then the first surface plot disappers. Could you please let me know how I could combine the two kind of plots ? Thanks. Hello all,
I would like to plot a 3D plot in which I plot some scattered 3D points and at the same time I would like to plot surfaces which correspond to the limits of the ranges of my three variables. I attach a .dat file which contains the variables, the variable ‘parameters’ contain the 3D data which to be plotted, they are 500 data points for each of the three variables. The variables p1, p2 and p3 contain the ranges of my three variables, I would like to plot the surfaces which correspond to the limits of these variables, for example for the third variable, this will do the job for the lower limit:
surf(p3(1)*ones(size(parameters,2),size(parameters,2)),’FaceColor’,’r’,’FaceAlpha’,0.3,’EdgeColor’,’none’)
I have a problem which is that after I use the command plot3 to plot the data as follows:
figure(‘units’,’normalized’,’outerposition’,[0 0 1 1])
surf(p3(1)*ones(size(parameters,2),size(parameters,2)),’FaceColor’,’r’,’FaceAlpha’,0.3,’EdgeColor’,’none’)
hold on
plot3(parameters(1,:),parameters(2,:),parameters(3,:),’*r’,’MarkerSize’,15)
hold on
plot3(parameters(1,IDEIM_mu),parameters(2,IDEIM_mu),parameters(3,IDEIM_mu),’ko’,’MarkerSize’,20)
xlim([0.8*p1(1) 1.2*p1(2)]);
ylim([0.8*p2(1) 1.2*p2(2)]);
zlim([0.8*p3(1) 1.2*p3(2)]);
Then the first surface plot disappers. Could you please let me know how I could combine the two kind of plots ? Thanks. plot3, surf MATLAB Answers — New Questions
Can I use DAQ board that doesn’t support by Simulink Desktop Real-Time I/O library for real time simulation? If can, what should I do to achieve it?
I want to use a self-made DAQ board for simulink desktop real time, with connecting my computor and DAQ board through serial port. But everytime I run the simulation, error "The board ‘Standard Devices Serial Port’ has no Analog Input channels." occurs. How to solve this problem?I want to use a self-made DAQ board for simulink desktop real time, with connecting my computor and DAQ board through serial port. But everytime I run the simulation, error "The board ‘Standard Devices Serial Port’ has no Analog Input channels." occurs. How to solve this problem? I want to use a self-made DAQ board for simulink desktop real time, with connecting my computor and DAQ board through serial port. But everytime I run the simulation, error "The board ‘Standard Devices Serial Port’ has no Analog Input channels." occurs. How to solve this problem? simulink desktop real time MATLAB Answers — New Questions
export stripchart data using matlab
i want to export the data of stripchart onto excel using matlab code after my schedule has finished runningi want to export the data of stripchart onto excel using matlab code after my schedule has finished running i want to export the data of stripchart onto excel using matlab code after my schedule has finished running help MATLAB Answers — New Questions
Why my deep learning network is producing NaN outputs?
I have a deep CNN network with 39 layers. While training the network is producing NaN output so the loss function is also producing NaN values. My network also has some custom layers which uses ‘dlconv’ where the weights are intialized using ‘initializeGlorot’ function. Why the network is producing ‘NaN’ outputs? Is there any way to solve this? Kindly request to provide suggestions.
Thanking,
BipinI have a deep CNN network with 39 layers. While training the network is producing NaN output so the loss function is also producing NaN values. My network also has some custom layers which uses ‘dlconv’ where the weights are intialized using ‘initializeGlorot’ function. Why the network is producing ‘NaN’ outputs? Is there any way to solve this? Kindly request to provide suggestions.
Thanking,
Bipin I have a deep CNN network with 39 layers. While training the network is producing NaN output so the loss function is also producing NaN values. My network also has some custom layers which uses ‘dlconv’ where the weights are intialized using ‘initializeGlorot’ function. Why the network is producing ‘NaN’ outputs? Is there any way to solve this? Kindly request to provide suggestions.
Thanking,
Bipin matlab, matlab gui, matlab code, deep learning, signal processing, digital signal processing, digital image processing, image processing, image, image analysis, image acquisition, image segmentation, signal, machine learning, matrix, matrices, matrix array, matrix manipulation, data, data preprocessing, deep learning toolbox, convolutional neural network, classification, class MATLAB Answers — New Questions
Niftiwrite throws error even when just saving the image
Hi, I was playing around with segementing/skull stripping and wanted to save the new image the the MRI header using niftiwrite. This gave me an error so I then tried to load the image and save it with the following code:
T1 = niftiread(fullfile(fpath, [‘mri/’, participant, ‘_T1.nii’]));
T1_info = niftiinfo(fullfile(fpath, [‘mri/’, participant, ‘_T1.nii’]));
niftiwrite(T1, ‘test.nii’, T1_info);
Which then gave me the following error:
Error using niftiwrite>parseInputs (line 175)
The value of ‘Info’ is invalid. Volume size does not match header size specified.
Error in niftiwrite (line 89)
[V, path, filename, params] = parseInputs(V, filename, varargin{:});
I’m not allowed to share the MRI but any ideas why this is happening? Thanks!Hi, I was playing around with segementing/skull stripping and wanted to save the new image the the MRI header using niftiwrite. This gave me an error so I then tried to load the image and save it with the following code:
T1 = niftiread(fullfile(fpath, [‘mri/’, participant, ‘_T1.nii’]));
T1_info = niftiinfo(fullfile(fpath, [‘mri/’, participant, ‘_T1.nii’]));
niftiwrite(T1, ‘test.nii’, T1_info);
Which then gave me the following error:
Error using niftiwrite>parseInputs (line 175)
The value of ‘Info’ is invalid. Volume size does not match header size specified.
Error in niftiwrite (line 89)
[V, path, filename, params] = parseInputs(V, filename, varargin{:});
I’m not allowed to share the MRI but any ideas why this is happening? Thanks! Hi, I was playing around with segementing/skull stripping and wanted to save the new image the the MRI header using niftiwrite. This gave me an error so I then tried to load the image and save it with the following code:
T1 = niftiread(fullfile(fpath, [‘mri/’, participant, ‘_T1.nii’]));
T1_info = niftiinfo(fullfile(fpath, [‘mri/’, participant, ‘_T1.nii’]));
niftiwrite(T1, ‘test.nii’, T1_info);
Which then gave me the following error:
Error using niftiwrite>parseInputs (line 175)
The value of ‘Info’ is invalid. Volume size does not match header size specified.
Error in niftiwrite (line 89)
[V, path, filename, params] = parseInputs(V, filename, varargin{:});
I’m not allowed to share the MRI but any ideas why this is happening? Thanks! image processing, matlab, matlab function MATLAB Answers — New Questions
Could MATLAB please provide rref() without the rational conversion?
I am having the same problem as described in:
https://au.mathworks.com/matlabcentral/answers/102622-why-does-rref-give-significantly-different-answers-than-for-solutions-of-some-systems-in-matlab
The answer given is an attached MATLAB file, "rrefNoRational.m" which is a copy of "rref.m" without the code that performs the rational conversion that is the cause of the problem. However, I cannot find the attached file. Could the file rrefNoRational.m please be provided?
Thank you for your time.I am having the same problem as described in:
https://au.mathworks.com/matlabcentral/answers/102622-why-does-rref-give-significantly-different-answers-than-for-solutions-of-some-systems-in-matlab
The answer given is an attached MATLAB file, "rrefNoRational.m" which is a copy of "rref.m" without the code that performs the rational conversion that is the cause of the problem. However, I cannot find the attached file. Could the file rrefNoRational.m please be provided?
Thank you for your time. I am having the same problem as described in:
https://au.mathworks.com/matlabcentral/answers/102622-why-does-rref-give-significantly-different-answers-than-for-solutions-of-some-systems-in-matlab
The answer given is an attached MATLAB file, "rrefNoRational.m" which is a copy of "rref.m" without the code that performs the rational conversion that is the cause of the problem. However, I cannot find the attached file. Could the file rrefNoRational.m please be provided?
Thank you for your time. rref, rrefrrefnorational MATLAB Answers — New Questions
Turn off compile mode
Hi,
I use Model([], [], [], ‘compile’) to set the model in compile mode before computing some checksums. After receiving the checksums I want to close the model but I get an error that the model can’t be closed since it is being compiled.
How do I turn off the compile mode?Hi,
I use Model([], [], [], ‘compile’) to set the model in compile mode before computing some checksums. After receiving the checksums I want to close the model but I get an error that the model can’t be closed since it is being compiled.
How do I turn off the compile mode? Hi,
I use Model([], [], [], ‘compile’) to set the model in compile mode before computing some checksums. After receiving the checksums I want to close the model but I get an error that the model can’t be closed since it is being compiled.
How do I turn off the compile mode? compiler, checksum MATLAB Answers — New Questions
HDL Coder Generation Error
I get the following error message.
"Error using hdlcoder.pirctx/balancePathDelays
Unexpected error during HDL Code Generation.
Contact support@mathworks.com with reproduction steps.
Assertion failed with debug message:
B:matlabsrccgir_hdlpir_transformsPropagateInitVal.cpp:204:getInitVal(s) == InitVal::NOT_VISITED"
It seems like the error is not always there. After matlab and computer restarts combined with mutliple tries i eventiually get "lucky" and able to generate hdl. The model contains simulink nr ldpc decoder which I suspect is the problem.I get the following error message.
"Error using hdlcoder.pirctx/balancePathDelays
Unexpected error during HDL Code Generation.
Contact support@mathworks.com with reproduction steps.
Assertion failed with debug message:
B:matlabsrccgir_hdlpir_transformsPropagateInitVal.cpp:204:getInitVal(s) == InitVal::NOT_VISITED"
It seems like the error is not always there. After matlab and computer restarts combined with mutliple tries i eventiually get "lucky" and able to generate hdl. The model contains simulink nr ldpc decoder which I suspect is the problem. I get the following error message.
"Error using hdlcoder.pirctx/balancePathDelays
Unexpected error during HDL Code Generation.
Contact support@mathworks.com with reproduction steps.
Assertion failed with debug message:
B:matlabsrccgir_hdlpir_transformsPropagateInitVal.cpp:204:getInitVal(s) == InitVal::NOT_VISITED"
It seems like the error is not always there. After matlab and computer restarts combined with mutliple tries i eventiually get "lucky" and able to generate hdl. The model contains simulink nr ldpc decoder which I suspect is the problem. hdl coder, nr ldpc decodeer MATLAB Answers — New Questions
Determine number of steps in a specific frequency cycle
I have a simulink model that outputs a continous step count at a constant rate. However, I would like to add a bit of code that inputs the step count and outputs the total number of steps taken in 1 second. I tried using a triggered subsystem that uses a pulse generator block, to no avail. Any help is greatly appreciated.I have a simulink model that outputs a continous step count at a constant rate. However, I would like to add a bit of code that inputs the step count and outputs the total number of steps taken in 1 second. I tried using a triggered subsystem that uses a pulse generator block, to no avail. Any help is greatly appreciated. I have a simulink model that outputs a continous step count at a constant rate. However, I would like to add a bit of code that inputs the step count and outputs the total number of steps taken in 1 second. I tried using a triggered subsystem that uses a pulse generator block, to no avail. Any help is greatly appreciated. simulink, discrete, time MATLAB Answers — New Questions
How to average frequency and a frequency over time graph all in Matlab?
Hello everyone,
I am encountering an issue with calculating the average frequency in MATLAB. The average frequency result is unexpectedly high and varies with each execution, even though the audio input remains unchanged. Conversely, using the same audio in Python yields more consistent and reasonable results.
If anyone can identify the problem and help fix my MATLAB code, it would be greatly appreciated. Below are two versions of the code: the first records sound directly in MATLAB, and the second processes an existing audio file.
Thank you for your assistance.
Best regards,
UMO
Code 1: also can’t figure out freq over time graph
clc
clear
warning off
Fs = 8000; % Sampling frequency in hertz
ch = 1; % Number of channels–2 options–>1 (mono) or 2 (stereo)
datatype = ‘uint8’;
nbits = 16; % 8, 16, or 24
Nseconds = 5;
% To record audio data from an input device …
% … such as a microphone for processing in MATLAB
recorder1 = audiorecorder(Fs, nbits, ch, 1); % Use device ID 1 for first microphone
% Record audio to audiorecorder object,…
% … hold control until recording completes
recordblocking(recorder1, Nseconds);
disp(‘End of Recording.’);
% Store recorded audio
x1 = getaudiodata(recorder1);
% Write audio file
audiowrite(‘test1.wav’, x1, Fs);
% Calculate time vector
t1 = 0:1/Fs:(length(x1)-1)/Fs;
% Plot time domain signal
figure;
subplot(2, 1, 1);
plot(t1, x1, ‘LineWidth’, 1.5);
xlabel(‘Time (sec)’);
ylabel(‘Amplitude’);
title(‘Time Domain Plot of the Recorded Signal’);
% Stat Information
maxValue = max(x1);
minValue = min(x1);
meanValue = mean(x1);
stdValue = std(x1);
rmsValue = rms(x1); % root mean square
% Display statistical information
disp(‘Statistical Information:’)
disp([‘Max Value: ‘, num2str(maxValue)])
disp([‘Min Value: ‘, num2str(minValue)])
disp([‘Mean Value: ‘, num2str(meanValue)])
disp([‘Standard Deviation: ‘, num2str(stdValue)])
disp([‘RMS Value: ‘, num2str(rmsValue)])
% Plot time domain signal
%figure;
% subplot(2, 1, 2);
%plot(t2, x2, ‘LineWidth’, 1.5);
%xlabel(‘Time (sec)’);
%ylabel(‘Amplitude’);
%title(‘Time Domain Plot of the Recorded Signal mirco 2’);
% Calculate FFt
n1 = length(x1);
Y1 = fft(x1);
F1 = Fs/n1*(0:n1-1);
% Find the average frequency
freq = meanfreq( x1 ,Fs );
disp([‘Average frequency of the recorded sound: ‘, num2str(freq), ‘ Hz’]);
% Plot frequency domain signal
% subplot(2, 1, 2);
figure;
plot(F1, abs(Y1(:,1)), ‘LineWidth’, 1.5);
xlabel(‘Frequency (Hz)’);
ylabel(‘Amplitude’);
title(‘Frequency Domain Plot of the Audio Signal’);
Code 2:
clc
clear
close all
warning off
% Reading input signal
[file, path] = uigetfile(‘*.wav’, ‘Select a WAV file’);
filename = fullfile(path, file);
[input_signal, Fs] = audioread(filename);
% Create time vector
t = (0:length(input_signal)-1) / Fs;
% Plotting time-domain signal
figure;
plot(t, input_signal);
grid on
title(‘Time Domain Signal’, ‘FontName’, ‘Times New Roman’, ‘FontSize’, 14);
xlabel(‘Time (sec)’, ‘FontName’, ‘Times New Roman’, ‘FontSize’, 12);
ylabel(‘Amplitude’, ‘FontName’, ‘Times New Roman’, ‘FontSize’, 12);
% Stat Information
maxValue = max(input_signal);
minValue = min(input_signal);
meanValue = mean(input_signal);
stdValue = std(input_signal);
rmsValue = rms(input_signal); % root mean square
% Display statistical information
disp(‘Statistical Information:’)
disp([‘Max Value: ‘, num2str(maxValue)])
disp([‘Min Value: ‘, num2str(minValue)])
disp([‘Mean Value: ‘, num2str(meanValue)])
disp([‘Standard Deviation: ‘, num2str(stdValue)])
disp([‘RMS Value: ‘, num2str(rmsValue)])
% Compute FFT
N = length(input_signal);
v = fft(input_signal);
v = v(1:N/2+1); % Keep only the positive frequencies
f = (0:N/2) * Fs / N; % Frequency vector
% Find the average frequency
freq = meanfreq(input_signal, Fs);
disp([‘Average frequency of the recorded sound: ‘, num2str(freq), ‘ Hz’]);
% find avg frequency manually
tfreq = sum(abs(input_signal).^2);
% Display the result
disp([‘Total frequency domain energy: ‘, num2str(tfreq)])Hello everyone,
I am encountering an issue with calculating the average frequency in MATLAB. The average frequency result is unexpectedly high and varies with each execution, even though the audio input remains unchanged. Conversely, using the same audio in Python yields more consistent and reasonable results.
If anyone can identify the problem and help fix my MATLAB code, it would be greatly appreciated. Below are two versions of the code: the first records sound directly in MATLAB, and the second processes an existing audio file.
Thank you for your assistance.
Best regards,
UMO
Code 1: also can’t figure out freq over time graph
clc
clear
warning off
Fs = 8000; % Sampling frequency in hertz
ch = 1; % Number of channels–2 options–>1 (mono) or 2 (stereo)
datatype = ‘uint8’;
nbits = 16; % 8, 16, or 24
Nseconds = 5;
% To record audio data from an input device …
% … such as a microphone for processing in MATLAB
recorder1 = audiorecorder(Fs, nbits, ch, 1); % Use device ID 1 for first microphone
% Record audio to audiorecorder object,…
% … hold control until recording completes
recordblocking(recorder1, Nseconds);
disp(‘End of Recording.’);
% Store recorded audio
x1 = getaudiodata(recorder1);
% Write audio file
audiowrite(‘test1.wav’, x1, Fs);
% Calculate time vector
t1 = 0:1/Fs:(length(x1)-1)/Fs;
% Plot time domain signal
figure;
subplot(2, 1, 1);
plot(t1, x1, ‘LineWidth’, 1.5);
xlabel(‘Time (sec)’);
ylabel(‘Amplitude’);
title(‘Time Domain Plot of the Recorded Signal’);
% Stat Information
maxValue = max(x1);
minValue = min(x1);
meanValue = mean(x1);
stdValue = std(x1);
rmsValue = rms(x1); % root mean square
% Display statistical information
disp(‘Statistical Information:’)
disp([‘Max Value: ‘, num2str(maxValue)])
disp([‘Min Value: ‘, num2str(minValue)])
disp([‘Mean Value: ‘, num2str(meanValue)])
disp([‘Standard Deviation: ‘, num2str(stdValue)])
disp([‘RMS Value: ‘, num2str(rmsValue)])
% Plot time domain signal
%figure;
% subplot(2, 1, 2);
%plot(t2, x2, ‘LineWidth’, 1.5);
%xlabel(‘Time (sec)’);
%ylabel(‘Amplitude’);
%title(‘Time Domain Plot of the Recorded Signal mirco 2’);
% Calculate FFt
n1 = length(x1);
Y1 = fft(x1);
F1 = Fs/n1*(0:n1-1);
% Find the average frequency
freq = meanfreq( x1 ,Fs );
disp([‘Average frequency of the recorded sound: ‘, num2str(freq), ‘ Hz’]);
% Plot frequency domain signal
% subplot(2, 1, 2);
figure;
plot(F1, abs(Y1(:,1)), ‘LineWidth’, 1.5);
xlabel(‘Frequency (Hz)’);
ylabel(‘Amplitude’);
title(‘Frequency Domain Plot of the Audio Signal’);
Code 2:
clc
clear
close all
warning off
% Reading input signal
[file, path] = uigetfile(‘*.wav’, ‘Select a WAV file’);
filename = fullfile(path, file);
[input_signal, Fs] = audioread(filename);
% Create time vector
t = (0:length(input_signal)-1) / Fs;
% Plotting time-domain signal
figure;
plot(t, input_signal);
grid on
title(‘Time Domain Signal’, ‘FontName’, ‘Times New Roman’, ‘FontSize’, 14);
xlabel(‘Time (sec)’, ‘FontName’, ‘Times New Roman’, ‘FontSize’, 12);
ylabel(‘Amplitude’, ‘FontName’, ‘Times New Roman’, ‘FontSize’, 12);
% Stat Information
maxValue = max(input_signal);
minValue = min(input_signal);
meanValue = mean(input_signal);
stdValue = std(input_signal);
rmsValue = rms(input_signal); % root mean square
% Display statistical information
disp(‘Statistical Information:’)
disp([‘Max Value: ‘, num2str(maxValue)])
disp([‘Min Value: ‘, num2str(minValue)])
disp([‘Mean Value: ‘, num2str(meanValue)])
disp([‘Standard Deviation: ‘, num2str(stdValue)])
disp([‘RMS Value: ‘, num2str(rmsValue)])
% Compute FFT
N = length(input_signal);
v = fft(input_signal);
v = v(1:N/2+1); % Keep only the positive frequencies
f = (0:N/2) * Fs / N; % Frequency vector
% Find the average frequency
freq = meanfreq(input_signal, Fs);
disp([‘Average frequency of the recorded sound: ‘, num2str(freq), ‘ Hz’]);
% find avg frequency manually
tfreq = sum(abs(input_signal).^2);
% Display the result
disp([‘Total frequency domain energy: ‘, num2str(tfreq)]) Hello everyone,
I am encountering an issue with calculating the average frequency in MATLAB. The average frequency result is unexpectedly high and varies with each execution, even though the audio input remains unchanged. Conversely, using the same audio in Python yields more consistent and reasonable results.
If anyone can identify the problem and help fix my MATLAB code, it would be greatly appreciated. Below are two versions of the code: the first records sound directly in MATLAB, and the second processes an existing audio file.
Thank you for your assistance.
Best regards,
UMO
Code 1: also can’t figure out freq over time graph
clc
clear
warning off
Fs = 8000; % Sampling frequency in hertz
ch = 1; % Number of channels–2 options–>1 (mono) or 2 (stereo)
datatype = ‘uint8’;
nbits = 16; % 8, 16, or 24
Nseconds = 5;
% To record audio data from an input device …
% … such as a microphone for processing in MATLAB
recorder1 = audiorecorder(Fs, nbits, ch, 1); % Use device ID 1 for first microphone
% Record audio to audiorecorder object,…
% … hold control until recording completes
recordblocking(recorder1, Nseconds);
disp(‘End of Recording.’);
% Store recorded audio
x1 = getaudiodata(recorder1);
% Write audio file
audiowrite(‘test1.wav’, x1, Fs);
% Calculate time vector
t1 = 0:1/Fs:(length(x1)-1)/Fs;
% Plot time domain signal
figure;
subplot(2, 1, 1);
plot(t1, x1, ‘LineWidth’, 1.5);
xlabel(‘Time (sec)’);
ylabel(‘Amplitude’);
title(‘Time Domain Plot of the Recorded Signal’);
% Stat Information
maxValue = max(x1);
minValue = min(x1);
meanValue = mean(x1);
stdValue = std(x1);
rmsValue = rms(x1); % root mean square
% Display statistical information
disp(‘Statistical Information:’)
disp([‘Max Value: ‘, num2str(maxValue)])
disp([‘Min Value: ‘, num2str(minValue)])
disp([‘Mean Value: ‘, num2str(meanValue)])
disp([‘Standard Deviation: ‘, num2str(stdValue)])
disp([‘RMS Value: ‘, num2str(rmsValue)])
% Plot time domain signal
%figure;
% subplot(2, 1, 2);
%plot(t2, x2, ‘LineWidth’, 1.5);
%xlabel(‘Time (sec)’);
%ylabel(‘Amplitude’);
%title(‘Time Domain Plot of the Recorded Signal mirco 2’);
% Calculate FFt
n1 = length(x1);
Y1 = fft(x1);
F1 = Fs/n1*(0:n1-1);
% Find the average frequency
freq = meanfreq( x1 ,Fs );
disp([‘Average frequency of the recorded sound: ‘, num2str(freq), ‘ Hz’]);
% Plot frequency domain signal
% subplot(2, 1, 2);
figure;
plot(F1, abs(Y1(:,1)), ‘LineWidth’, 1.5);
xlabel(‘Frequency (Hz)’);
ylabel(‘Amplitude’);
title(‘Frequency Domain Plot of the Audio Signal’);
Code 2:
clc
clear
close all
warning off
% Reading input signal
[file, path] = uigetfile(‘*.wav’, ‘Select a WAV file’);
filename = fullfile(path, file);
[input_signal, Fs] = audioread(filename);
% Create time vector
t = (0:length(input_signal)-1) / Fs;
% Plotting time-domain signal
figure;
plot(t, input_signal);
grid on
title(‘Time Domain Signal’, ‘FontName’, ‘Times New Roman’, ‘FontSize’, 14);
xlabel(‘Time (sec)’, ‘FontName’, ‘Times New Roman’, ‘FontSize’, 12);
ylabel(‘Amplitude’, ‘FontName’, ‘Times New Roman’, ‘FontSize’, 12);
% Stat Information
maxValue = max(input_signal);
minValue = min(input_signal);
meanValue = mean(input_signal);
stdValue = std(input_signal);
rmsValue = rms(input_signal); % root mean square
% Display statistical information
disp(‘Statistical Information:’)
disp([‘Max Value: ‘, num2str(maxValue)])
disp([‘Min Value: ‘, num2str(minValue)])
disp([‘Mean Value: ‘, num2str(meanValue)])
disp([‘Standard Deviation: ‘, num2str(stdValue)])
disp([‘RMS Value: ‘, num2str(rmsValue)])
% Compute FFT
N = length(input_signal);
v = fft(input_signal);
v = v(1:N/2+1); % Keep only the positive frequencies
f = (0:N/2) * Fs / N; % Frequency vector
% Find the average frequency
freq = meanfreq(input_signal, Fs);
disp([‘Average frequency of the recorded sound: ‘, num2str(freq), ‘ Hz’]);
% find avg frequency manually
tfreq = sum(abs(input_signal).^2);
% Display the result
disp([‘Total frequency domain energy: ‘, num2str(tfreq)]) frequency, meanfreq, meanfrequency, frequencyovertime, graph, help MATLAB Answers — New Questions
Generate VST Plug-in from Simulink Model
Hello,
I have a Simulink model of an audio processing algorithm. I would like to generate a VST plug-in from this model.
Is this possible?
Thank you,
Michael.Hello,
I have a Simulink model of an audio processing algorithm. I would like to generate a VST plug-in from this model.
Is this possible?
Thank you,
Michael. Hello,
I have a Simulink model of an audio processing algorithm. I would like to generate a VST plug-in from this model.
Is this possible?
Thank you,
Michael. simulink vst plugin MATLAB Answers — New Questions
How to interprete an analytical eigendecomposition for a polynomial matrix with size nxn > 4×4 using the Symbolic Math Toolbox.
Hi,
I am using the Symbolic Math Toolbox to calculate the analytical eigenvalues of a polynomial matrix A(z), that is generated in my physical use-case. Depending on the input parameters, the matrix can scale in size from 1×1 to any nxn.
If I configure my matrix to have a size nxn > 4×4, the symbolic math toolbox still produces analytical eigenvalues (i.e. a polynomials without the "root" expression). How does Matlab calculate the analytical Eigenvalues in this particular case?
According to an answer to my previous question: https://www.mathworks.com/matlabcentral/answers/2132636-how-does-matlabs-symbolic-math-toolbox-always-finds-an-analytical-eigendecomposition-for-arbitrary-p#answer_1478061, Matlab uses numerical methods to find the roots of the characteristic polynomial.
However, from my experience the symbolic toolbox does not provide an analytic expression (i.e. a polynomial), if numerical methods where used and the solution is purely numerical. So my question is how Matlab arrives at this result?
Does Matlab indeed use a numerical approximation?
Does Matlab do some "tricks" in the background to reformulate my matrix into some analytically solvable matrix?
I also have attached a copy of my Matrix in a 6×6 configuration and the corresponding result.
Note: the variable "y" in my matrix represents 1/z, but this shouldn’t make a difference.
My code does the following:
syms z y
A = A;
A_roots = eig(A);Hi,
I am using the Symbolic Math Toolbox to calculate the analytical eigenvalues of a polynomial matrix A(z), that is generated in my physical use-case. Depending on the input parameters, the matrix can scale in size from 1×1 to any nxn.
If I configure my matrix to have a size nxn > 4×4, the symbolic math toolbox still produces analytical eigenvalues (i.e. a polynomials without the "root" expression). How does Matlab calculate the analytical Eigenvalues in this particular case?
According to an answer to my previous question: https://www.mathworks.com/matlabcentral/answers/2132636-how-does-matlabs-symbolic-math-toolbox-always-finds-an-analytical-eigendecomposition-for-arbitrary-p#answer_1478061, Matlab uses numerical methods to find the roots of the characteristic polynomial.
However, from my experience the symbolic toolbox does not provide an analytic expression (i.e. a polynomial), if numerical methods where used and the solution is purely numerical. So my question is how Matlab arrives at this result?
Does Matlab indeed use a numerical approximation?
Does Matlab do some "tricks" in the background to reformulate my matrix into some analytically solvable matrix?
I also have attached a copy of my Matrix in a 6×6 configuration and the corresponding result.
Note: the variable "y" in my matrix represents 1/z, but this shouldn’t make a difference.
My code does the following:
syms z y
A = A;
A_roots = eig(A); Hi,
I am using the Symbolic Math Toolbox to calculate the analytical eigenvalues of a polynomial matrix A(z), that is generated in my physical use-case. Depending on the input parameters, the matrix can scale in size from 1×1 to any nxn.
If I configure my matrix to have a size nxn > 4×4, the symbolic math toolbox still produces analytical eigenvalues (i.e. a polynomials without the "root" expression). How does Matlab calculate the analytical Eigenvalues in this particular case?
According to an answer to my previous question: https://www.mathworks.com/matlabcentral/answers/2132636-how-does-matlabs-symbolic-math-toolbox-always-finds-an-analytical-eigendecomposition-for-arbitrary-p#answer_1478061, Matlab uses numerical methods to find the roots of the characteristic polynomial.
However, from my experience the symbolic toolbox does not provide an analytic expression (i.e. a polynomial), if numerical methods where used and the solution is purely numerical. So my question is how Matlab arrives at this result?
Does Matlab indeed use a numerical approximation?
Does Matlab do some "tricks" in the background to reformulate my matrix into some analytically solvable matrix?
I also have attached a copy of my Matrix in a 6×6 configuration and the corresponding result.
Note: the variable "y" in my matrix represents 1/z, but this shouldn’t make a difference.
My code does the following:
syms z y
A = A;
A_roots = eig(A); symbolic-math, polynomial-matrices, eigenvalues MATLAB Answers — New Questions
Why does eig return different eigen values depending on whether eigen vector outputs are specified ?
I have the below 11×11 matrix (it is stored in P_sym.mat file attached). I get different eigen values from eig depenind on how I call it. If it computes eigen vectors it returns different eigen values than if I call eig with just eigen values specified as outputs.
For the following code, where i = 4
[v, d] = eig(P_sym,’vector’);
[dxx] = eig(P_sym);
p_sym_ispostitive_definate(i) = issymmetric(P_sym) && all(d > 0.0);
if(min(d) > 0 && min(dxx) < 0)
save(‘P_sym.mat’,’P_sym’);
fprintf(1,’P_sym : %15.8e %15.8e %15.8e %15.8e %15.8e %15.8e %15.8e %15.8e %15.8e %15.8e %15.8en’,squeeze(P_sym));
fprintf(1,’n’);
p_sym_ispostitive_definateXX = issymmetric(P_sym) && all(dxx > 0.0);
fprintf(1,[‘ P_sym(%d) SPD %d, symmetric %d, min_eig %15.8e, eig: ‘ repmat(‘ %15.8e’,1,length(dxx)) ‘n’],i,p_sym_ispostitive_definateXX, issymmetric(P_sym), min(dxx), dxx);
fprintf(1,’n’);
keyboard
end
I get the folllowing results:
P_sym(1) SPD 1, symmetric 1, min_eig 8.90819724e-23, eig: 8.90819724e-23 8.01292127e-16 7.71071265e-12 1.83508980e-11 2.71554045e-09 3.24460252e-09 4.31101082e-03 4.04842334e-02 2.91492831e-01 1.00000000e+00 9.47720644e+00
P_sym : 2.86443726e-01 1.25605442e-01 -3.05677616e-02 3.17320309e-05 -1.41410366e-07 1.37827270e-05 0.00000000e+00 0.00000000e+00 -1.93544065e-02 -4.36768322e-07 -3.54926546e-12
P_sym : 1.25605442e-01 7.12565604e+00 -4.08080640e+00 4.76436787e-04 8.15871206e-04 -2.98861979e-04 0.00000000e+00 0.00000000e+00 -7.64780930e-02 -5.97081660e-07 -2.54538005e-12
P_sym : -3.05677616e-02 -4.08080640e+00 2.38619512e+00 -2.69887758e-04 -4.67183802e-04 1.83109375e-04 0.00000000e+00 0.00000000e+00 2.29324963e-02 -4.59895084e-07 -6.02605228e-12
P_sym : 3.17320309e-05 4.76436787e-04 -2.69887758e-04 3.61675592e-08 5.22270400e-08 -1.98733607e-08 0.00000000e+00 0.00000000e+00 -8.24258261e-06 -2.22346600e-10 -1.93099984e-15
P_sym : -1.41410366e-07 8.15871206e-04 -4.67183802e-04 5.22270400e-08 9.67373610e-08 -3.56665330e-08 0.00000000e+00 0.00000000e+00 -8.10157851e-06 -2.75926708e-11 -5.27412767e-17
P_sym : 1.37827270e-05 -2.98861979e-04 1.83109375e-04 -1.98733607e-08 -3.56665330e-08 1.78452469e-08 0.00000000e+00 0.00000000e+00 -6.41479546e-07 -6.32077553e-11 -5.51581323e-16
P_sym : 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 1.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00
P_sym : 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 1.00000000e-18 0.00000000e+00 0.00000000e+00 0.00000000e+00
P_sym : -1.93544065e-02 -7.64780930e-02 2.29324963e-02 -8.24258261e-06 -8.10157851e-06 -6.41479546e-07 0.00000000e+00 0.00000000e+00 1.51994891e-02 6.47038249e-07 6.14697206e-12
P_sym : -4.36768322e-07 -5.97081660e-07 -4.59895084e-07 -2.22346600e-10 -2.75926708e-11 -6.32077553e-11 0.00000000e+00 0.00000000e+00 6.47038249e-07 4.01852424e-11 4.26210532e-16
P_sym : -3.54926546e-12 -2.54538005e-12 -6.02605228e-12 -1.93099984e-15 -5.27412767e-17 -5.51581323e-16 0.00000000e+00 0.00000000e+00 6.14697206e-12 4.26210532e-16 4.76317051e-21
P_sym(1) SPD 0, symmetric 1, min_eig -3.56878675e-17, eig: -3.56878675e-17 8.91986312e-23 7.71020397e-12 1.83488208e-11 2.71554106e-09 3.24460241e-09 4.31101082e-03 4.04842334e-02 2.91492831e-01 1.00000000e+00 9.47720644e+00
This is rather perplexing, because the minimum eigen value in the first call is positive, whereas in the 2nd call it is negative. This defines whether the matrix is positive definate or not. The difference that causes the output change is not the "vector" output option for eig, but rather whether eigen vectors are requested in the return.
Why the differing values? Which eig can be used with assurance to determine SPD (symmetric positive definate) matrices??
P_sym : 3.91971950e-01 -1.84707196e-02 9.64010847e-02 1.49471956e-05 -2.95043186e-05 8.41762906e-06 0.00000000e+00 0.00000000e+00 -2.63518244e-02 -8.89506787e-07 -7.63950369e-12
P_sym : -1.84707196e-02 1.10109548e+01 -5.54536247e+00 7.12947029e-04 5.49185331e-04 9.97089694e-06 0.00000000e+00 0.00000000e+00 -1.00683513e-01 -8.04754882e-07 -3.84179497e-12
P_sym : 9.64010847e-02 -5.54536247e+00 2.97740884e+00 -3.66348740e-04 -2.70925828e-04 2.66675852e-05 0.00000000e+00 0.00000000e+00 1.37117248e-02 -7.52066065e-07 -8.08110708e-12
P_sym : 1.49471956e-05 7.12947029e-04 -3.66348740e-04 4.89069796e-08 3.30828980e-08 -1.44659120e-09 0.00000000e+00 0.00000000e+00 -8.18935868e-06 -1.82559412e-10 -1.48511352e-15
P_sym : -2.95043186e-05 5.49185331e-04 -2.70925828e-04 3.30828980e-08 3.19074916e-08 1.18059503e-09 0.00000000e+00 0.00000000e+00 -4.85944277e-06 -1.22536049e-11 -4.65286216e-17
P_sym : 8.41762906e-06 9.97089694e-06 2.66675852e-05 -1.44659120e-09 1.18059503e-09 6.54728043e-09 0.00000000e+00 0.00000000e+00 -4.94291834e-06 -1.19356169e-10 -9.10766108e-16
P_sym : 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 1.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00
P_sym : 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 1.00000000e-18 0.00000000e+00 0.00000000e+00 0.00000000e+00
P_sym : -2.63518244e-02 -1.00683513e-01 1.37117248e-02 -8.18935868e-06 -4.85944277e-06 -4.94291834e-06 0.00000000e+00 0.00000000e+00 1.90931002e-02 7.98240784e-07 7.33246401e-12
P_sym : -8.89506787e-07 -8.04754882e-07 -7.52066065e-07 -1.82559412e-10 -1.22536049e-11 -1.19356169e-10 0.00000000e+00 0.00000000e+00 7.98240784e-07 4.49272102e-11 4.51931653e-16
P_sym : -7.63950369e-12 -3.84179497e-12 -8.08110708e-12 -1.48511352e-15 -4.65286216e-17 -9.10766108e-16 0.00000000e+00 0.00000000e+00 7.33246401e-12 4.51931653e-16 4.76317051e-21I have the below 11×11 matrix (it is stored in P_sym.mat file attached). I get different eigen values from eig depenind on how I call it. If it computes eigen vectors it returns different eigen values than if I call eig with just eigen values specified as outputs.
For the following code, where i = 4
[v, d] = eig(P_sym,’vector’);
[dxx] = eig(P_sym);
p_sym_ispostitive_definate(i) = issymmetric(P_sym) && all(d > 0.0);
if(min(d) > 0 && min(dxx) < 0)
save(‘P_sym.mat’,’P_sym’);
fprintf(1,’P_sym : %15.8e %15.8e %15.8e %15.8e %15.8e %15.8e %15.8e %15.8e %15.8e %15.8e %15.8en’,squeeze(P_sym));
fprintf(1,’n’);
p_sym_ispostitive_definateXX = issymmetric(P_sym) && all(dxx > 0.0);
fprintf(1,[‘ P_sym(%d) SPD %d, symmetric %d, min_eig %15.8e, eig: ‘ repmat(‘ %15.8e’,1,length(dxx)) ‘n’],i,p_sym_ispostitive_definateXX, issymmetric(P_sym), min(dxx), dxx);
fprintf(1,’n’);
keyboard
end
I get the folllowing results:
P_sym(1) SPD 1, symmetric 1, min_eig 8.90819724e-23, eig: 8.90819724e-23 8.01292127e-16 7.71071265e-12 1.83508980e-11 2.71554045e-09 3.24460252e-09 4.31101082e-03 4.04842334e-02 2.91492831e-01 1.00000000e+00 9.47720644e+00
P_sym : 2.86443726e-01 1.25605442e-01 -3.05677616e-02 3.17320309e-05 -1.41410366e-07 1.37827270e-05 0.00000000e+00 0.00000000e+00 -1.93544065e-02 -4.36768322e-07 -3.54926546e-12
P_sym : 1.25605442e-01 7.12565604e+00 -4.08080640e+00 4.76436787e-04 8.15871206e-04 -2.98861979e-04 0.00000000e+00 0.00000000e+00 -7.64780930e-02 -5.97081660e-07 -2.54538005e-12
P_sym : -3.05677616e-02 -4.08080640e+00 2.38619512e+00 -2.69887758e-04 -4.67183802e-04 1.83109375e-04 0.00000000e+00 0.00000000e+00 2.29324963e-02 -4.59895084e-07 -6.02605228e-12
P_sym : 3.17320309e-05 4.76436787e-04 -2.69887758e-04 3.61675592e-08 5.22270400e-08 -1.98733607e-08 0.00000000e+00 0.00000000e+00 -8.24258261e-06 -2.22346600e-10 -1.93099984e-15
P_sym : -1.41410366e-07 8.15871206e-04 -4.67183802e-04 5.22270400e-08 9.67373610e-08 -3.56665330e-08 0.00000000e+00 0.00000000e+00 -8.10157851e-06 -2.75926708e-11 -5.27412767e-17
P_sym : 1.37827270e-05 -2.98861979e-04 1.83109375e-04 -1.98733607e-08 -3.56665330e-08 1.78452469e-08 0.00000000e+00 0.00000000e+00 -6.41479546e-07 -6.32077553e-11 -5.51581323e-16
P_sym : 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 1.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00
P_sym : 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 1.00000000e-18 0.00000000e+00 0.00000000e+00 0.00000000e+00
P_sym : -1.93544065e-02 -7.64780930e-02 2.29324963e-02 -8.24258261e-06 -8.10157851e-06 -6.41479546e-07 0.00000000e+00 0.00000000e+00 1.51994891e-02 6.47038249e-07 6.14697206e-12
P_sym : -4.36768322e-07 -5.97081660e-07 -4.59895084e-07 -2.22346600e-10 -2.75926708e-11 -6.32077553e-11 0.00000000e+00 0.00000000e+00 6.47038249e-07 4.01852424e-11 4.26210532e-16
P_sym : -3.54926546e-12 -2.54538005e-12 -6.02605228e-12 -1.93099984e-15 -5.27412767e-17 -5.51581323e-16 0.00000000e+00 0.00000000e+00 6.14697206e-12 4.26210532e-16 4.76317051e-21
P_sym(1) SPD 0, symmetric 1, min_eig -3.56878675e-17, eig: -3.56878675e-17 8.91986312e-23 7.71020397e-12 1.83488208e-11 2.71554106e-09 3.24460241e-09 4.31101082e-03 4.04842334e-02 2.91492831e-01 1.00000000e+00 9.47720644e+00
This is rather perplexing, because the minimum eigen value in the first call is positive, whereas in the 2nd call it is negative. This defines whether the matrix is positive definate or not. The difference that causes the output change is not the "vector" output option for eig, but rather whether eigen vectors are requested in the return.
Why the differing values? Which eig can be used with assurance to determine SPD (symmetric positive definate) matrices??
P_sym : 3.91971950e-01 -1.84707196e-02 9.64010847e-02 1.49471956e-05 -2.95043186e-05 8.41762906e-06 0.00000000e+00 0.00000000e+00 -2.63518244e-02 -8.89506787e-07 -7.63950369e-12
P_sym : -1.84707196e-02 1.10109548e+01 -5.54536247e+00 7.12947029e-04 5.49185331e-04 9.97089694e-06 0.00000000e+00 0.00000000e+00 -1.00683513e-01 -8.04754882e-07 -3.84179497e-12
P_sym : 9.64010847e-02 -5.54536247e+00 2.97740884e+00 -3.66348740e-04 -2.70925828e-04 2.66675852e-05 0.00000000e+00 0.00000000e+00 1.37117248e-02 -7.52066065e-07 -8.08110708e-12
P_sym : 1.49471956e-05 7.12947029e-04 -3.66348740e-04 4.89069796e-08 3.30828980e-08 -1.44659120e-09 0.00000000e+00 0.00000000e+00 -8.18935868e-06 -1.82559412e-10 -1.48511352e-15
P_sym : -2.95043186e-05 5.49185331e-04 -2.70925828e-04 3.30828980e-08 3.19074916e-08 1.18059503e-09 0.00000000e+00 0.00000000e+00 -4.85944277e-06 -1.22536049e-11 -4.65286216e-17
P_sym : 8.41762906e-06 9.97089694e-06 2.66675852e-05 -1.44659120e-09 1.18059503e-09 6.54728043e-09 0.00000000e+00 0.00000000e+00 -4.94291834e-06 -1.19356169e-10 -9.10766108e-16
P_sym : 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 1.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00
P_sym : 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 1.00000000e-18 0.00000000e+00 0.00000000e+00 0.00000000e+00
P_sym : -2.63518244e-02 -1.00683513e-01 1.37117248e-02 -8.18935868e-06 -4.85944277e-06 -4.94291834e-06 0.00000000e+00 0.00000000e+00 1.90931002e-02 7.98240784e-07 7.33246401e-12
P_sym : -8.89506787e-07 -8.04754882e-07 -7.52066065e-07 -1.82559412e-10 -1.22536049e-11 -1.19356169e-10 0.00000000e+00 0.00000000e+00 7.98240784e-07 4.49272102e-11 4.51931653e-16
P_sym : -7.63950369e-12 -3.84179497e-12 -8.08110708e-12 -1.48511352e-15 -4.65286216e-17 -9.10766108e-16 0.00000000e+00 0.00000000e+00 7.33246401e-12 4.51931653e-16 4.76317051e-21 I have the below 11×11 matrix (it is stored in P_sym.mat file attached). I get different eigen values from eig depenind on how I call it. If it computes eigen vectors it returns different eigen values than if I call eig with just eigen values specified as outputs.
For the following code, where i = 4
[v, d] = eig(P_sym,’vector’);
[dxx] = eig(P_sym);
p_sym_ispostitive_definate(i) = issymmetric(P_sym) && all(d > 0.0);
if(min(d) > 0 && min(dxx) < 0)
save(‘P_sym.mat’,’P_sym’);
fprintf(1,’P_sym : %15.8e %15.8e %15.8e %15.8e %15.8e %15.8e %15.8e %15.8e %15.8e %15.8e %15.8en’,squeeze(P_sym));
fprintf(1,’n’);
p_sym_ispostitive_definateXX = issymmetric(P_sym) && all(dxx > 0.0);
fprintf(1,[‘ P_sym(%d) SPD %d, symmetric %d, min_eig %15.8e, eig: ‘ repmat(‘ %15.8e’,1,length(dxx)) ‘n’],i,p_sym_ispostitive_definateXX, issymmetric(P_sym), min(dxx), dxx);
fprintf(1,’n’);
keyboard
end
I get the folllowing results:
P_sym(1) SPD 1, symmetric 1, min_eig 8.90819724e-23, eig: 8.90819724e-23 8.01292127e-16 7.71071265e-12 1.83508980e-11 2.71554045e-09 3.24460252e-09 4.31101082e-03 4.04842334e-02 2.91492831e-01 1.00000000e+00 9.47720644e+00
P_sym : 2.86443726e-01 1.25605442e-01 -3.05677616e-02 3.17320309e-05 -1.41410366e-07 1.37827270e-05 0.00000000e+00 0.00000000e+00 -1.93544065e-02 -4.36768322e-07 -3.54926546e-12
P_sym : 1.25605442e-01 7.12565604e+00 -4.08080640e+00 4.76436787e-04 8.15871206e-04 -2.98861979e-04 0.00000000e+00 0.00000000e+00 -7.64780930e-02 -5.97081660e-07 -2.54538005e-12
P_sym : -3.05677616e-02 -4.08080640e+00 2.38619512e+00 -2.69887758e-04 -4.67183802e-04 1.83109375e-04 0.00000000e+00 0.00000000e+00 2.29324963e-02 -4.59895084e-07 -6.02605228e-12
P_sym : 3.17320309e-05 4.76436787e-04 -2.69887758e-04 3.61675592e-08 5.22270400e-08 -1.98733607e-08 0.00000000e+00 0.00000000e+00 -8.24258261e-06 -2.22346600e-10 -1.93099984e-15
P_sym : -1.41410366e-07 8.15871206e-04 -4.67183802e-04 5.22270400e-08 9.67373610e-08 -3.56665330e-08 0.00000000e+00 0.00000000e+00 -8.10157851e-06 -2.75926708e-11 -5.27412767e-17
P_sym : 1.37827270e-05 -2.98861979e-04 1.83109375e-04 -1.98733607e-08 -3.56665330e-08 1.78452469e-08 0.00000000e+00 0.00000000e+00 -6.41479546e-07 -6.32077553e-11 -5.51581323e-16
P_sym : 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 1.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00
P_sym : 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 1.00000000e-18 0.00000000e+00 0.00000000e+00 0.00000000e+00
P_sym : -1.93544065e-02 -7.64780930e-02 2.29324963e-02 -8.24258261e-06 -8.10157851e-06 -6.41479546e-07 0.00000000e+00 0.00000000e+00 1.51994891e-02 6.47038249e-07 6.14697206e-12
P_sym : -4.36768322e-07 -5.97081660e-07 -4.59895084e-07 -2.22346600e-10 -2.75926708e-11 -6.32077553e-11 0.00000000e+00 0.00000000e+00 6.47038249e-07 4.01852424e-11 4.26210532e-16
P_sym : -3.54926546e-12 -2.54538005e-12 -6.02605228e-12 -1.93099984e-15 -5.27412767e-17 -5.51581323e-16 0.00000000e+00 0.00000000e+00 6.14697206e-12 4.26210532e-16 4.76317051e-21
P_sym(1) SPD 0, symmetric 1, min_eig -3.56878675e-17, eig: -3.56878675e-17 8.91986312e-23 7.71020397e-12 1.83488208e-11 2.71554106e-09 3.24460241e-09 4.31101082e-03 4.04842334e-02 2.91492831e-01 1.00000000e+00 9.47720644e+00
This is rather perplexing, because the minimum eigen value in the first call is positive, whereas in the 2nd call it is negative. This defines whether the matrix is positive definate or not. The difference that causes the output change is not the "vector" output option for eig, but rather whether eigen vectors are requested in the return.
Why the differing values? Which eig can be used with assurance to determine SPD (symmetric positive definate) matrices??
P_sym : 3.91971950e-01 -1.84707196e-02 9.64010847e-02 1.49471956e-05 -2.95043186e-05 8.41762906e-06 0.00000000e+00 0.00000000e+00 -2.63518244e-02 -8.89506787e-07 -7.63950369e-12
P_sym : -1.84707196e-02 1.10109548e+01 -5.54536247e+00 7.12947029e-04 5.49185331e-04 9.97089694e-06 0.00000000e+00 0.00000000e+00 -1.00683513e-01 -8.04754882e-07 -3.84179497e-12
P_sym : 9.64010847e-02 -5.54536247e+00 2.97740884e+00 -3.66348740e-04 -2.70925828e-04 2.66675852e-05 0.00000000e+00 0.00000000e+00 1.37117248e-02 -7.52066065e-07 -8.08110708e-12
P_sym : 1.49471956e-05 7.12947029e-04 -3.66348740e-04 4.89069796e-08 3.30828980e-08 -1.44659120e-09 0.00000000e+00 0.00000000e+00 -8.18935868e-06 -1.82559412e-10 -1.48511352e-15
P_sym : -2.95043186e-05 5.49185331e-04 -2.70925828e-04 3.30828980e-08 3.19074916e-08 1.18059503e-09 0.00000000e+00 0.00000000e+00 -4.85944277e-06 -1.22536049e-11 -4.65286216e-17
P_sym : 8.41762906e-06 9.97089694e-06 2.66675852e-05 -1.44659120e-09 1.18059503e-09 6.54728043e-09 0.00000000e+00 0.00000000e+00 -4.94291834e-06 -1.19356169e-10 -9.10766108e-16
P_sym : 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 1.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00
P_sym : 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 1.00000000e-18 0.00000000e+00 0.00000000e+00 0.00000000e+00
P_sym : -2.63518244e-02 -1.00683513e-01 1.37117248e-02 -8.18935868e-06 -4.85944277e-06 -4.94291834e-06 0.00000000e+00 0.00000000e+00 1.90931002e-02 7.98240784e-07 7.33246401e-12
P_sym : -8.89506787e-07 -8.04754882e-07 -7.52066065e-07 -1.82559412e-10 -1.22536049e-11 -1.19356169e-10 0.00000000e+00 0.00000000e+00 7.98240784e-07 4.49272102e-11 4.51931653e-16
P_sym : -7.63950369e-12 -3.84179497e-12 -8.08110708e-12 -1.48511352e-15 -4.65286216e-17 -9.10766108e-16 0.00000000e+00 0.00000000e+00 7.33246401e-12 4.51931653e-16 4.76317051e-21 eig, symmetric positive definite MATLAB Answers — New Questions
Calling subclass functions to manipulate inputs for superclass constructor?
I have a user-created subclass Domain2d < fegeometry. The fegeometry class is a default class in MATLAB, and the inputs for the fegeometry constructor are not user-friendly. Part of the idea of the Domain2d subclass is that its constructor should take user-friendly inputs, translate them into the complex inputs needed for the fegeometry constructor, then call the fegeometry constructor. The way the code is currently written, the task of manipulating the simple inputs into complex inputs is like:
classdef Domain2d < fegeometry
properties
end
methods
function self = Domain2d(simple_inputs)
% manipulate simple_inputs to complex_inputs
…(code here)
% call superclass constructor
self@fegeometry(complex_inputs);
end
end
end
This is kludge-y, but it works, and substantial code has been written that uses the bar object. But now I have a good reason to want to rewrite the bar object like
classdef Domain2d < fegeometry
properties
end
methods
function self = Domain2d(simple_inputs)
complex_inputs = translateSimpleToComplex(self,simple_inputs);
self@fegeometry(complex_inputs);
end
function complex_inputs = translateSimpleToComplex(self,simple_inputs)
…
end
end
end
The above produces the error "Calling the superclass constructor ‘fegeometry’ after an object use or after a return statement is not supported."
How should I proceed?I have a user-created subclass Domain2d < fegeometry. The fegeometry class is a default class in MATLAB, and the inputs for the fegeometry constructor are not user-friendly. Part of the idea of the Domain2d subclass is that its constructor should take user-friendly inputs, translate them into the complex inputs needed for the fegeometry constructor, then call the fegeometry constructor. The way the code is currently written, the task of manipulating the simple inputs into complex inputs is like:
classdef Domain2d < fegeometry
properties
end
methods
function self = Domain2d(simple_inputs)
% manipulate simple_inputs to complex_inputs
…(code here)
% call superclass constructor
self@fegeometry(complex_inputs);
end
end
end
This is kludge-y, but it works, and substantial code has been written that uses the bar object. But now I have a good reason to want to rewrite the bar object like
classdef Domain2d < fegeometry
properties
end
methods
function self = Domain2d(simple_inputs)
complex_inputs = translateSimpleToComplex(self,simple_inputs);
self@fegeometry(complex_inputs);
end
function complex_inputs = translateSimpleToComplex(self,simple_inputs)
…
end
end
end
The above produces the error "Calling the superclass constructor ‘fegeometry’ after an object use or after a return statement is not supported."
How should I proceed? I have a user-created subclass Domain2d < fegeometry. The fegeometry class is a default class in MATLAB, and the inputs for the fegeometry constructor are not user-friendly. Part of the idea of the Domain2d subclass is that its constructor should take user-friendly inputs, translate them into the complex inputs needed for the fegeometry constructor, then call the fegeometry constructor. The way the code is currently written, the task of manipulating the simple inputs into complex inputs is like:
classdef Domain2d < fegeometry
properties
end
methods
function self = Domain2d(simple_inputs)
% manipulate simple_inputs to complex_inputs
…(code here)
% call superclass constructor
self@fegeometry(complex_inputs);
end
end
end
This is kludge-y, but it works, and substantial code has been written that uses the bar object. But now I have a good reason to want to rewrite the bar object like
classdef Domain2d < fegeometry
properties
end
methods
function self = Domain2d(simple_inputs)
complex_inputs = translateSimpleToComplex(self,simple_inputs);
self@fegeometry(complex_inputs);
end
function complex_inputs = translateSimpleToComplex(self,simple_inputs)
…
end
end
end
The above produces the error "Calling the superclass constructor ‘fegeometry’ after an object use or after a return statement is not supported."
How should I proceed? classes, inheritance, constructors MATLAB Answers — New Questions
Return of handle, which was selected with ‘ButtonDownFcn’
Hey there,
I plotted some data in just one figure, after that, I want to select some plots by mouse in the figure and I want to highlight it by increasing the ‘LineWidth’ and get the information, which of the plotted object has been selected.
In my main script, I use the following code to call the function (dxf.handle contains all the handles, which have been plotted before):
selected_entities = sub_select(dxf.handle);
The function has the following code:
function selected_object = sub_select(H)
set(H, ‘ButtonDownFcn’, selected_object = @LineSelected)
end
function ObjectH = LineSelected(ObjectH, EventData)
set(ObjectH, ‘LineWidth’, 2.5);
end
In general the code works and it’s possible to highlight the objects, but I didn’t get the information, which handle was selected. This information should be stored in selected_entities. At the moment, I just get this:
selected_object = @LineSelected
Thanks in advance for your help.
Best regards
DanielHey there,
I plotted some data in just one figure, after that, I want to select some plots by mouse in the figure and I want to highlight it by increasing the ‘LineWidth’ and get the information, which of the plotted object has been selected.
In my main script, I use the following code to call the function (dxf.handle contains all the handles, which have been plotted before):
selected_entities = sub_select(dxf.handle);
The function has the following code:
function selected_object = sub_select(H)
set(H, ‘ButtonDownFcn’, selected_object = @LineSelected)
end
function ObjectH = LineSelected(ObjectH, EventData)
set(ObjectH, ‘LineWidth’, 2.5);
end
In general the code works and it’s possible to highlight the objects, but I didn’t get the information, which handle was selected. This information should be stored in selected_entities. At the moment, I just get this:
selected_object = @LineSelected
Thanks in advance for your help.
Best regards
Daniel Hey there,
I plotted some data in just one figure, after that, I want to select some plots by mouse in the figure and I want to highlight it by increasing the ‘LineWidth’ and get the information, which of the plotted object has been selected.
In my main script, I use the following code to call the function (dxf.handle contains all the handles, which have been plotted before):
selected_entities = sub_select(dxf.handle);
The function has the following code:
function selected_object = sub_select(H)
set(H, ‘ButtonDownFcn’, selected_object = @LineSelected)
end
function ObjectH = LineSelected(ObjectH, EventData)
set(ObjectH, ‘LineWidth’, 2.5);
end
In general the code works and it’s possible to highlight the objects, but I didn’t get the information, which handle was selected. This information should be stored in selected_entities. At the moment, I just get this:
selected_object = @LineSelected
Thanks in advance for your help.
Best regards
Daniel ‘buttondownfcn’ MATLAB Answers — New Questions
How do I find the phase for a periodic cos wave using fft?
I have a simple cos wave that has a period, in this case 6. I am offsetting the wave by an angular amount with phase. How can I use the fft function to recover back my initial phase offset? I tried converting the fourier transformed value with the highest amplitude (abs) which does correclty identify the period back to a phase using angle, but this never seems to work. If someone could enlighten me as to how to do this, I would be so grateful! (Edit: I would like to see how to correctly recover the original period as well)
n = 1e3;
a = linspace(0, 2*pi, n);
period = 6;
phase = rand * 2*pi;
f = rescale(cos((a-phase)*pr));I have a simple cos wave that has a period, in this case 6. I am offsetting the wave by an angular amount with phase. How can I use the fft function to recover back my initial phase offset? I tried converting the fourier transformed value with the highest amplitude (abs) which does correclty identify the period back to a phase using angle, but this never seems to work. If someone could enlighten me as to how to do this, I would be so grateful! (Edit: I would like to see how to correctly recover the original period as well)
n = 1e3;
a = linspace(0, 2*pi, n);
period = 6;
phase = rand * 2*pi;
f = rescale(cos((a-phase)*pr)); I have a simple cos wave that has a period, in this case 6. I am offsetting the wave by an angular amount with phase. How can I use the fft function to recover back my initial phase offset? I tried converting the fourier transformed value with the highest amplitude (abs) which does correclty identify the period back to a phase using angle, but this never seems to work. If someone could enlighten me as to how to do this, I would be so grateful! (Edit: I would like to see how to correctly recover the original period as well)
n = 1e3;
a = linspace(0, 2*pi, n);
period = 6;
phase = rand * 2*pi;
f = rescale(cos((a-phase)*pr)); fourier, fft, phase MATLAB Answers — New Questions
Wireless channel modeling: Error using plot Specify the coordinates as vectors or matrices of the same size, or as a vector and a matrix that share the same length in at least
betaTT=90; %
betaRR=90;
Ft_max=570;
Fr_max=570;
alphavT=0;
alphavR=0;
kappa=0;
Ut=45;
tau=0;
Freq_diff=0;
D=300;
Rt=40;
Fc=5.9*10^9;
C=3*10^8;
deltaT=2;
N=20;
% Conversion from degree to radian
betaT=(2*pi*betaTT)/360;
betaR=(2*pi*betaRR)/360;
alpha_0=(2*pi*Ut)/360;
lamda=0.15;
deltaR=linspace(0,2.5,200);
% CF_SB1=zeros(length(deltaT),length(deltaR));
% lambda=(Fc/C);
change_inT=40/300;
alphaT=linspace(-pi,pi,200);
% alphaT=zeros(1,length(alphaT));
for i=1:length(alphaT)
% if (alphaT(i)>-pi)&(alphaT(i)<=pi)
alphaR(i)=pi-(change_inT*sin(alphaT(i)));
end
for b=1:length(deltaR);
% for c=1:length(deltaT);
O=deltaT*cos(alphaT-betaT);
Q=deltaR(b).*cos(alphaR(i)-(betaR));
CF_SB1(b)=(1/(2*pi*besseli(0,kappa)))*trapz(alphaT,exp(sqrt(-1)*2*pi)*(Q+O));
end
figure(1)
plot(deltaR,real(CF_SB1),’–g’);
set(0,’DefaultAxesFontSize’,18);betaTT=90; %
betaRR=90;
Ft_max=570;
Fr_max=570;
alphavT=0;
alphavR=0;
kappa=0;
Ut=45;
tau=0;
Freq_diff=0;
D=300;
Rt=40;
Fc=5.9*10^9;
C=3*10^8;
deltaT=2;
N=20;
% Conversion from degree to radian
betaT=(2*pi*betaTT)/360;
betaR=(2*pi*betaRR)/360;
alpha_0=(2*pi*Ut)/360;
lamda=0.15;
deltaR=linspace(0,2.5,200);
% CF_SB1=zeros(length(deltaT),length(deltaR));
% lambda=(Fc/C);
change_inT=40/300;
alphaT=linspace(-pi,pi,200);
% alphaT=zeros(1,length(alphaT));
for i=1:length(alphaT)
% if (alphaT(i)>-pi)&(alphaT(i)<=pi)
alphaR(i)=pi-(change_inT*sin(alphaT(i)));
end
for b=1:length(deltaR);
% for c=1:length(deltaT);
O=deltaT*cos(alphaT-betaT);
Q=deltaR(b).*cos(alphaR(i)-(betaR));
CF_SB1(b)=(1/(2*pi*besseli(0,kappa)))*trapz(alphaT,exp(sqrt(-1)*2*pi)*(Q+O));
end
figure(1)
plot(deltaR,real(CF_SB1),’–g’);
set(0,’DefaultAxesFontSize’,18); betaTT=90; %
betaRR=90;
Ft_max=570;
Fr_max=570;
alphavT=0;
alphavR=0;
kappa=0;
Ut=45;
tau=0;
Freq_diff=0;
D=300;
Rt=40;
Fc=5.9*10^9;
C=3*10^8;
deltaT=2;
N=20;
% Conversion from degree to radian
betaT=(2*pi*betaTT)/360;
betaR=(2*pi*betaRR)/360;
alpha_0=(2*pi*Ut)/360;
lamda=0.15;
deltaR=linspace(0,2.5,200);
% CF_SB1=zeros(length(deltaT),length(deltaR));
% lambda=(Fc/C);
change_inT=40/300;
alphaT=linspace(-pi,pi,200);
% alphaT=zeros(1,length(alphaT));
for i=1:length(alphaT)
% if (alphaT(i)>-pi)&(alphaT(i)<=pi)
alphaR(i)=pi-(change_inT*sin(alphaT(i)));
end
for b=1:length(deltaR);
% for c=1:length(deltaT);
O=deltaT*cos(alphaT-betaT);
Q=deltaR(b).*cos(alphaR(i)-(betaR));
CF_SB1(b)=(1/(2*pi*besseli(0,kappa)))*trapz(alphaT,exp(sqrt(-1)*2*pi)*(Q+O));
end
figure(1)
plot(deltaR,real(CF_SB1),’–g’);
set(0,’DefaultAxesFontSize’,18); space-time-frequency correlation function MATLAB Answers — New Questions
How do I install matlab engine to be able to use matlab functions in an anaconda environment?
I am using MATLAB R2024a and anaconda v24.1.2. I am trying to install matlab.engine on a specific anaconda environment, but when I naviagte to the setup.py file in the matlabroot directory tree I get the error:
C:Userssteve.condaenvs3d_model_analysisLibsite-packagessetuptools_distutilscmd.py:66: SetuptoolsDeprecationWarning: setup.py install is deprecated.
!!
********************************************************************************
Please avoid running “setup.py“ directly.
Instead, use pypa/build, pypa/installer or other
standards-based tools.
See https://blog.ganssle.io/articles/2021/10/setup-py-deprecated.html for details.
********************************************************************************
!!
self.initialize_options()
C:Userssteve.condaenvs3d_model_analysisLibsite-packagessetuptools_distutilscmd.py:66: EasyInstallDeprecationWarning: easy_install command is deprecated.
!!
********************************************************************************
Please avoid running “setup.py“ and “easy_install“.
Instead, use pypa/build, pypa/installer or other
standards-based tools.
See https://github.com/pypa/setuptools/issues/917 for details.
********************************************************************************
!!
self.initialize_options()
TEST FAILED: C:Userssteve.condapkgsLibsite-packages does NOT support .pth files
bad install directory or PYTHONPATH
You are attempting to install a package to a directory that is not
on PYTHONPATH and which Python does not read ".pth" files from. The
installation directory you specified (via –install-dir, –prefix, or
the distutils default setting) was:
C:Userssteve.condapkgsLibsite-packages
and your PYTHONPATH environment variable currently contains:
”
Here are some of your options for correcting the problem:
* You can choose a different installation directory, i.e., one that is
on PYTHONPATH or supports .pth files
* You can add the installation directory to the PYTHONPATH environment
variable. (It must then also be on PYTHONPATH whenever you run
Python and want to use the package(s) you are installing.)
* You can set up the installation directory to support ".pth" files by
using one of the approaches described here:
https://setuptools.pypa.io/en/latest/deprecated/easy_install.html#custom-installation-locations
Please make the appropriate changes for your system and try again.
C:Userssteve.condaenvs3d_model_analysisLibsite-packagessetuptoolscommandsdist.py:117: SetuptoolsDeprecationWarning: `build_py` command does not inherit from setuptools’ `build_py`.
!!
********************************************************************************
Custom ‘build_py’ does not implement ‘get_data_files_without_manifest’.
Please extend command classes from setuptools instead of distutils.
See https://peps.python.org/pep-0632/ for details.
********************************************************************************
!!
self._add_data_files(self._safe_data_files(build_py))
zip_safe flag not set; analyzing archive contents…
matlab.__pycache__.__init__.cpython-311: module references __file__
matlab.__pycache__.__init__.cpython-311: module references __path__
matlab.engine.__pycache__.__init__.cpython-311: module references __file__
(3d_model_analysis) C:Program FilesMATLABR2024aexternenginespython>python setup.py install –prefix "C:/Users/steve/.conda/pkgs"
C:Userssteve.condaenvs3d_model_analysisLibsite-packagessetuptools_distutilscmd.py:66: SetuptoolsDeprecationWarning: setup.py install is deprecated.
!!
********************************************************************************
Please avoid running “setup.py“ directly.
Instead, use pypa/build, pypa/installer or other
standards-based tools.
See https://blog.ganssle.io/articles/2021/10/setup-py-deprecated.html for details.
********************************************************************************
!!
self.initialize_options()
C:Userssteve.condaenvs3d_model_analysisLibsite-packagessetuptools_distutilscmd.py:66: EasyInstallDeprecationWarning: easy_install command is deprecated.
!!
********************************************************************************
Please avoid running “setup.py“ and “easy_install“.
Instead, use pypa/build, pypa/installer or other
standards-based tools.
See https://github.com/pypa/setuptools/issues/917 for details.
********************************************************************************
!!
self.initialize_options()
TEST FAILED: C:Userssteve.condapkgsLibsite-packages does NOT support .pth files
bad install directory or PYTHONPATH
You are attempting to install a package to a directory that is not
on PYTHONPATH and which Python does not read ".pth" files from. The
installation directory you specified (via –install-dir, –prefix, or
the distutils default setting) was:
C:Userssteve.condapkgsLibsite-packages
and your PYTHONPATH environment variable currently contains:
”
Here are some of your options for correcting the problem:
* You can choose a different installation directory, i.e., one that is
on PYTHONPATH or supports .pth files
* You can add the installation directory to the PYTHONPATH environment
variable. (It must then also be on PYTHONPATH whenever you run
Python and want to use the package(s) you are installing.)
* You can set up the installation directory to support ".pth" files by
using one of the approaches described here:
https://setuptools.pypa.io/en/latest/deprecated/easy_install.html#custom-installation-locations
Please make the appropriate changes for your system and try again.
C:Userssteve.condaenvs3d_model_analysisLibsite-packagessetuptoolscommandsdist.py:117: SetuptoolsDeprecationWarning: `build_py` command does not inherit from setuptools’ `build_py`.
!!
********************************************************************************
Custom ‘build_py’ does not implement ‘get_data_files_without_manifest’.
Please extend command classes from setuptools instead of distutils.
See https://peps.python.org/pep-0632/ for details.
********************************************************************************
!!
self._add_data_files(self._safe_data_files(build_py))
zip_safe flag not set; analyzing archive contents…
matlab.__pycache__.__init__.cpython-311: module references __file__
matlab.__pycache__.__init__.cpython-311: module references __path__
matlab.engine.__pycache__.__init__.cpython-311: module references __file__I am using MATLAB R2024a and anaconda v24.1.2. I am trying to install matlab.engine on a specific anaconda environment, but when I naviagte to the setup.py file in the matlabroot directory tree I get the error:
C:Userssteve.condaenvs3d_model_analysisLibsite-packagessetuptools_distutilscmd.py:66: SetuptoolsDeprecationWarning: setup.py install is deprecated.
!!
********************************************************************************
Please avoid running “setup.py“ directly.
Instead, use pypa/build, pypa/installer or other
standards-based tools.
See https://blog.ganssle.io/articles/2021/10/setup-py-deprecated.html for details.
********************************************************************************
!!
self.initialize_options()
C:Userssteve.condaenvs3d_model_analysisLibsite-packagessetuptools_distutilscmd.py:66: EasyInstallDeprecationWarning: easy_install command is deprecated.
!!
********************************************************************************
Please avoid running “setup.py“ and “easy_install“.
Instead, use pypa/build, pypa/installer or other
standards-based tools.
See https://github.com/pypa/setuptools/issues/917 for details.
********************************************************************************
!!
self.initialize_options()
TEST FAILED: C:Userssteve.condapkgsLibsite-packages does NOT support .pth files
bad install directory or PYTHONPATH
You are attempting to install a package to a directory that is not
on PYTHONPATH and which Python does not read ".pth" files from. The
installation directory you specified (via –install-dir, –prefix, or
the distutils default setting) was:
C:Userssteve.condapkgsLibsite-packages
and your PYTHONPATH environment variable currently contains:
”
Here are some of your options for correcting the problem:
* You can choose a different installation directory, i.e., one that is
on PYTHONPATH or supports .pth files
* You can add the installation directory to the PYTHONPATH environment
variable. (It must then also be on PYTHONPATH whenever you run
Python and want to use the package(s) you are installing.)
* You can set up the installation directory to support ".pth" files by
using one of the approaches described here:
https://setuptools.pypa.io/en/latest/deprecated/easy_install.html#custom-installation-locations
Please make the appropriate changes for your system and try again.
C:Userssteve.condaenvs3d_model_analysisLibsite-packagessetuptoolscommandsdist.py:117: SetuptoolsDeprecationWarning: `build_py` command does not inherit from setuptools’ `build_py`.
!!
********************************************************************************
Custom ‘build_py’ does not implement ‘get_data_files_without_manifest’.
Please extend command classes from setuptools instead of distutils.
See https://peps.python.org/pep-0632/ for details.
********************************************************************************
!!
self._add_data_files(self._safe_data_files(build_py))
zip_safe flag not set; analyzing archive contents…
matlab.__pycache__.__init__.cpython-311: module references __file__
matlab.__pycache__.__init__.cpython-311: module references __path__
matlab.engine.__pycache__.__init__.cpython-311: module references __file__
(3d_model_analysis) C:Program FilesMATLABR2024aexternenginespython>python setup.py install –prefix "C:/Users/steve/.conda/pkgs"
C:Userssteve.condaenvs3d_model_analysisLibsite-packagessetuptools_distutilscmd.py:66: SetuptoolsDeprecationWarning: setup.py install is deprecated.
!!
********************************************************************************
Please avoid running “setup.py“ directly.
Instead, use pypa/build, pypa/installer or other
standards-based tools.
See https://blog.ganssle.io/articles/2021/10/setup-py-deprecated.html for details.
********************************************************************************
!!
self.initialize_options()
C:Userssteve.condaenvs3d_model_analysisLibsite-packagessetuptools_distutilscmd.py:66: EasyInstallDeprecationWarning: easy_install command is deprecated.
!!
********************************************************************************
Please avoid running “setup.py“ and “easy_install“.
Instead, use pypa/build, pypa/installer or other
standards-based tools.
See https://github.com/pypa/setuptools/issues/917 for details.
********************************************************************************
!!
self.initialize_options()
TEST FAILED: C:Userssteve.condapkgsLibsite-packages does NOT support .pth files
bad install directory or PYTHONPATH
You are attempting to install a package to a directory that is not
on PYTHONPATH and which Python does not read ".pth" files from. The
installation directory you specified (via –install-dir, –prefix, or
the distutils default setting) was:
C:Userssteve.condapkgsLibsite-packages
and your PYTHONPATH environment variable currently contains:
”
Here are some of your options for correcting the problem:
* You can choose a different installation directory, i.e., one that is
on PYTHONPATH or supports .pth files
* You can add the installation directory to the PYTHONPATH environment
variable. (It must then also be on PYTHONPATH whenever you run
Python and want to use the package(s) you are installing.)
* You can set up the installation directory to support ".pth" files by
using one of the approaches described here:
https://setuptools.pypa.io/en/latest/deprecated/easy_install.html#custom-installation-locations
Please make the appropriate changes for your system and try again.
C:Userssteve.condaenvs3d_model_analysisLibsite-packagessetuptoolscommandsdist.py:117: SetuptoolsDeprecationWarning: `build_py` command does not inherit from setuptools’ `build_py`.
!!
********************************************************************************
Custom ‘build_py’ does not implement ‘get_data_files_without_manifest’.
Please extend command classes from setuptools instead of distutils.
See https://peps.python.org/pep-0632/ for details.
********************************************************************************
!!
self._add_data_files(self._safe_data_files(build_py))
zip_safe flag not set; analyzing archive contents…
matlab.__pycache__.__init__.cpython-311: module references __file__
matlab.__pycache__.__init__.cpython-311: module references __path__
matlab.engine.__pycache__.__init__.cpython-311: module references __file__ I am using MATLAB R2024a and anaconda v24.1.2. I am trying to install matlab.engine on a specific anaconda environment, but when I naviagte to the setup.py file in the matlabroot directory tree I get the error:
C:Userssteve.condaenvs3d_model_analysisLibsite-packagessetuptools_distutilscmd.py:66: SetuptoolsDeprecationWarning: setup.py install is deprecated.
!!
********************************************************************************
Please avoid running “setup.py“ directly.
Instead, use pypa/build, pypa/installer or other
standards-based tools.
See https://blog.ganssle.io/articles/2021/10/setup-py-deprecated.html for details.
********************************************************************************
!!
self.initialize_options()
C:Userssteve.condaenvs3d_model_analysisLibsite-packagessetuptools_distutilscmd.py:66: EasyInstallDeprecationWarning: easy_install command is deprecated.
!!
********************************************************************************
Please avoid running “setup.py“ and “easy_install“.
Instead, use pypa/build, pypa/installer or other
standards-based tools.
See https://github.com/pypa/setuptools/issues/917 for details.
********************************************************************************
!!
self.initialize_options()
TEST FAILED: C:Userssteve.condapkgsLibsite-packages does NOT support .pth files
bad install directory or PYTHONPATH
You are attempting to install a package to a directory that is not
on PYTHONPATH and which Python does not read ".pth" files from. The
installation directory you specified (via –install-dir, –prefix, or
the distutils default setting) was:
C:Userssteve.condapkgsLibsite-packages
and your PYTHONPATH environment variable currently contains:
”
Here are some of your options for correcting the problem:
* You can choose a different installation directory, i.e., one that is
on PYTHONPATH or supports .pth files
* You can add the installation directory to the PYTHONPATH environment
variable. (It must then also be on PYTHONPATH whenever you run
Python and want to use the package(s) you are installing.)
* You can set up the installation directory to support ".pth" files by
using one of the approaches described here:
https://setuptools.pypa.io/en/latest/deprecated/easy_install.html#custom-installation-locations
Please make the appropriate changes for your system and try again.
C:Userssteve.condaenvs3d_model_analysisLibsite-packagessetuptoolscommandsdist.py:117: SetuptoolsDeprecationWarning: `build_py` command does not inherit from setuptools’ `build_py`.
!!
********************************************************************************
Custom ‘build_py’ does not implement ‘get_data_files_without_manifest’.
Please extend command classes from setuptools instead of distutils.
See https://peps.python.org/pep-0632/ for details.
********************************************************************************
!!
self._add_data_files(self._safe_data_files(build_py))
zip_safe flag not set; analyzing archive contents…
matlab.__pycache__.__init__.cpython-311: module references __file__
matlab.__pycache__.__init__.cpython-311: module references __path__
matlab.engine.__pycache__.__init__.cpython-311: module references __file__
(3d_model_analysis) C:Program FilesMATLABR2024aexternenginespython>python setup.py install –prefix "C:/Users/steve/.conda/pkgs"
C:Userssteve.condaenvs3d_model_analysisLibsite-packagessetuptools_distutilscmd.py:66: SetuptoolsDeprecationWarning: setup.py install is deprecated.
!!
********************************************************************************
Please avoid running “setup.py“ directly.
Instead, use pypa/build, pypa/installer or other
standards-based tools.
See https://blog.ganssle.io/articles/2021/10/setup-py-deprecated.html for details.
********************************************************************************
!!
self.initialize_options()
C:Userssteve.condaenvs3d_model_analysisLibsite-packagessetuptools_distutilscmd.py:66: EasyInstallDeprecationWarning: easy_install command is deprecated.
!!
********************************************************************************
Please avoid running “setup.py“ and “easy_install“.
Instead, use pypa/build, pypa/installer or other
standards-based tools.
See https://github.com/pypa/setuptools/issues/917 for details.
********************************************************************************
!!
self.initialize_options()
TEST FAILED: C:Userssteve.condapkgsLibsite-packages does NOT support .pth files
bad install directory or PYTHONPATH
You are attempting to install a package to a directory that is not
on PYTHONPATH and which Python does not read ".pth" files from. The
installation directory you specified (via –install-dir, –prefix, or
the distutils default setting) was:
C:Userssteve.condapkgsLibsite-packages
and your PYTHONPATH environment variable currently contains:
”
Here are some of your options for correcting the problem:
* You can choose a different installation directory, i.e., one that is
on PYTHONPATH or supports .pth files
* You can add the installation directory to the PYTHONPATH environment
variable. (It must then also be on PYTHONPATH whenever you run
Python and want to use the package(s) you are installing.)
* You can set up the installation directory to support ".pth" files by
using one of the approaches described here:
https://setuptools.pypa.io/en/latest/deprecated/easy_install.html#custom-installation-locations
Please make the appropriate changes for your system and try again.
C:Userssteve.condaenvs3d_model_analysisLibsite-packagessetuptoolscommandsdist.py:117: SetuptoolsDeprecationWarning: `build_py` command does not inherit from setuptools’ `build_py`.
!!
********************************************************************************
Custom ‘build_py’ does not implement ‘get_data_files_without_manifest’.
Please extend command classes from setuptools instead of distutils.
See https://peps.python.org/pep-0632/ for details.
********************************************************************************
!!
self._add_data_files(self._safe_data_files(build_py))
zip_safe flag not set; analyzing archive contents…
matlab.__pycache__.__init__.cpython-311: module references __file__
matlab.__pycache__.__init__.cpython-311: module references __path__
matlab.engine.__pycache__.__init__.cpython-311: module references __file__ matlab.engine, python, matlab MATLAB Answers — New Questions