Tag Archives: matlab
system call to another compiled exe in compiled script does not work
I have a compiled exe from another script in matlab, i wrote a wrapper to run it in parallel also in matlab, i compiled to an exe file, but when i run it, the system function can not call it.
system(my_prog.exe)
it does not work 🙁 when i compiled the script.I have a compiled exe from another script in matlab, i wrote a wrapper to run it in parallel also in matlab, i compiled to an exe file, but when i run it, the system function can not call it.
system(my_prog.exe)
it does not work 🙁 when i compiled the script. I have a compiled exe from another script in matlab, i wrote a wrapper to run it in parallel also in matlab, i compiled to an exe file, but when i run it, the system function can not call it.
system(my_prog.exe)
it does not work 🙁 when i compiled the script. system, compiler MATLAB Answers — New Questions
spline error: The first input must contain unique values.
I am defining a semicircle profile and then finding the x and y coordinate using interpolation at gauss legendres points
r = 0.35;
theta= linspace(pi/2,-pi/2,51);
xq = r*cos(theta);
yq = r*sin(theta)+r;
L = max(xq);
xn = xq/L;
x = spline(xn,xq,xx); %xx are gauss legendres quadrature points along x axis
y = spline(xq,yq,x);
while running the code it is showing error :Error using chckxy
The first input must contain unique values.
Error in spline
[x,y,sizey,endslopes] = chckxy(x,y);
x = spline(xn,xq,xx);
since the profile is semi circle there is duplicate x coordinates. how do i solve this error ?I am defining a semicircle profile and then finding the x and y coordinate using interpolation at gauss legendres points
r = 0.35;
theta= linspace(pi/2,-pi/2,51);
xq = r*cos(theta);
yq = r*sin(theta)+r;
L = max(xq);
xn = xq/L;
x = spline(xn,xq,xx); %xx are gauss legendres quadrature points along x axis
y = spline(xq,yq,x);
while running the code it is showing error :Error using chckxy
The first input must contain unique values.
Error in spline
[x,y,sizey,endslopes] = chckxy(x,y);
x = spline(xn,xq,xx);
since the profile is semi circle there is duplicate x coordinates. how do i solve this error ? I am defining a semicircle profile and then finding the x and y coordinate using interpolation at gauss legendres points
r = 0.35;
theta= linspace(pi/2,-pi/2,51);
xq = r*cos(theta);
yq = r*sin(theta)+r;
L = max(xq);
xn = xq/L;
x = spline(xn,xq,xx); %xx are gauss legendres quadrature points along x axis
y = spline(xq,yq,x);
while running the code it is showing error :Error using chckxy
The first input must contain unique values.
Error in spline
[x,y,sizey,endslopes] = chckxy(x,y);
x = spline(xn,xq,xx);
since the profile is semi circle there is duplicate x coordinates. how do i solve this error ? spline, fem MATLAB Answers — New Questions
Version 2024b and ServiceHost
Hello,
From the following question/response here (https://www.mathworks.com/matlabcentral/answers/2111226-what-is-the-mathworks-service-host-and-why-is-it-running), it would appear that this and related services cannot currently be disabled.
Is there a setting we can use to write this data and run these services from a different directory other than ~/.MathWorks?
The issue we are facing in our HPC environment is users can run matlab from any number of compute nodes and each run is creating a node specific directory. Our user home directories are limted with quotas and we’re starting to receive complaints.
-ChrisHello,
From the following question/response here (https://www.mathworks.com/matlabcentral/answers/2111226-what-is-the-mathworks-service-host-and-why-is-it-running), it would appear that this and related services cannot currently be disabled.
Is there a setting we can use to write this data and run these services from a different directory other than ~/.MathWorks?
The issue we are facing in our HPC environment is users can run matlab from any number of compute nodes and each run is creating a node specific directory. Our user home directories are limted with quotas and we’re starting to receive complaints.
-Chris Hello,
From the following question/response here (https://www.mathworks.com/matlabcentral/answers/2111226-what-is-the-mathworks-service-host-and-why-is-it-running), it would appear that this and related services cannot currently be disabled.
Is there a setting we can use to write this data and run these services from a different directory other than ~/.MathWorks?
The issue we are facing in our HPC environment is users can run matlab from any number of compute nodes and each run is creating a node specific directory. Our user home directories are limted with quotas and we’re starting to receive complaints.
-Chris 2024b, hpc, servicehost MATLAB Answers — New Questions
I don’t know what’s going on and why is this happening.
So, my matlab app worked perfectly fine when i had 2023b version. I decided to update it to a newer version. When the new version was installed i ran the matlab and it didn’t run as usual. It didn’t have the default layout, and when i treid to make a script it returned me this error:I don’t know what to do. Can someone please help me?So, my matlab app worked perfectly fine when i had 2023b version. I decided to update it to a newer version. When the new version was installed i ran the matlab and it didn’t run as usual. It didn’t have the default layout, and when i treid to make a script it returned me this error:I don’t know what to do. Can someone please help me? So, my matlab app worked perfectly fine when i had 2023b version. I decided to update it to a newer version. When the new version was installed i ran the matlab and it didn’t run as usual. It didn’t have the default layout, and when i treid to make a script it returned me this error:I don’t know what to do. Can someone please help me? java, problem, matlab MATLAB Answers — New Questions
About Simulink Solar Energy Model
I have an assignment to do with Simulink, but I don’t know how to do it. I want to use solar energy to produce energy, then use a DC-DC converter to electrolyze water and generate hydrogen, which will be used in a PEM fuel cell to produce 9 kW of energy. In the final stage, I need to convert this energy to city electricity using a DC-AC converter. How can I do this? I would appreciate it if you could explain it through modeling without specific values.I have an assignment to do with Simulink, but I don’t know how to do it. I want to use solar energy to produce energy, then use a DC-DC converter to electrolyze water and generate hydrogen, which will be used in a PEM fuel cell to produce 9 kW of energy. In the final stage, I need to convert this energy to city electricity using a DC-AC converter. How can I do this? I would appreciate it if you could explain it through modeling without specific values. I have an assignment to do with Simulink, but I don’t know how to do it. I want to use solar energy to produce energy, then use a DC-DC converter to electrolyze water and generate hydrogen, which will be used in a PEM fuel cell to produce 9 kW of energy. In the final stage, I need to convert this energy to city electricity using a DC-AC converter. How can I do this? I would appreciate it if you could explain it through modeling without specific values. transferred MATLAB Answers — New Questions
Can I link a library or ojbect file built with one compiler to a MEX function built with a different compiler?
I am using MATLAB R2024a on a Windows machine to build and link a C++ MEX function to a C++ static library.
I am compiling the static library outside of MATLAB using a supported version of the MinGW C/C++ compiler. In MATLAB, I am using the "mex" function and a supported version of the Microsoft Visual C++ compiler.
Is this a supported workflow? And if not, what workaround is available for me?I am using MATLAB R2024a on a Windows machine to build and link a C++ MEX function to a C++ static library.
I am compiling the static library outside of MATLAB using a supported version of the MinGW C/C++ compiler. In MATLAB, I am using the "mex" function and a supported version of the Microsoft Visual C++ compiler.
Is this a supported workflow? And if not, what workaround is available for me? I am using MATLAB R2024a on a Windows machine to build and link a C++ MEX function to a C++ static library.
I am compiling the static library outside of MATLAB using a supported version of the MinGW C/C++ compiler. In MATLAB, I am using the "mex" function and a supported version of the Microsoft Visual C++ compiler.
Is this a supported workflow? And if not, what workaround is available for me? mex, compiler, staticlibrary MATLAB Answers — New Questions
How to pass a struct to a model reference instance?
Hi all,
I have a Simulink Parameter containing a struct that I would like to pass on to a model reference instance.
Using the parameter from the basae workspace is no problem, but I need to use different parameters for the individual instances.
My idea was to use the instance parameters, but it seems like I cannot use a struct there.
Data type "auto" is not allowed and struct is not available.
The parameters I’d like to pass on look like this:
Is there a way to use a struct as instance parameter?
Or is there maybe a totally different approach?
Any help would be highly appreciated. 🙂
Thanks!
ChristopherHi all,
I have a Simulink Parameter containing a struct that I would like to pass on to a model reference instance.
Using the parameter from the basae workspace is no problem, but I need to use different parameters for the individual instances.
My idea was to use the instance parameters, but it seems like I cannot use a struct there.
Data type "auto" is not allowed and struct is not available.
The parameters I’d like to pass on look like this:
Is there a way to use a struct as instance parameter?
Or is there maybe a totally different approach?
Any help would be highly appreciated. 🙂
Thanks!
Christopher Hi all,
I have a Simulink Parameter containing a struct that I would like to pass on to a model reference instance.
Using the parameter from the basae workspace is no problem, but I need to use different parameters for the individual instances.
My idea was to use the instance parameters, but it seems like I cannot use a struct there.
Data type "auto" is not allowed and struct is not available.
The parameters I’d like to pass on look like this:
Is there a way to use a struct as instance parameter?
Or is there maybe a totally different approach?
Any help would be highly appreciated. 🙂
Thanks!
Christopher instance parameters, simulink parameter, struct, model reference, instance MATLAB Answers — New Questions
calculate probability in MATLAB
THIS IS A MULTINOMIAL PROBABILITY DISTRIBUTION PROBLEM!
say we are given 4 outcome below along with the probabilities
Calculate the probability such that
my attempted code is
% Define the probabilities for each outcome
HH = 0.013;
HL = 0.267;
LH = 0.031;
LL = 0.689;
% Initialize the total probability
totalProbability = 0;
% Loop through possible counts for HL and LH
for nHL = 0:20
for nLH = 0:2
nHH = 0;
nLL = 100 – nHH – nHL – nLH
probability = mnpdf([nHH nHL nLH nLL], [HH HL LH LL])
totalProbability = totalProbability + probability;
end
end
% Display the result
disp([‘The total probability is: ‘, num2str(totalProbability)])
However the code gives the value 0.0056902 but the real answer is 0.00132705 so clearly something is wrong with my code.THIS IS A MULTINOMIAL PROBABILITY DISTRIBUTION PROBLEM!
say we are given 4 outcome below along with the probabilities
Calculate the probability such that
my attempted code is
% Define the probabilities for each outcome
HH = 0.013;
HL = 0.267;
LH = 0.031;
LL = 0.689;
% Initialize the total probability
totalProbability = 0;
% Loop through possible counts for HL and LH
for nHL = 0:20
for nLH = 0:2
nHH = 0;
nLL = 100 – nHH – nHL – nLH
probability = mnpdf([nHH nHL nLH nLL], [HH HL LH LL])
totalProbability = totalProbability + probability;
end
end
% Display the result
disp([‘The total probability is: ‘, num2str(totalProbability)])
However the code gives the value 0.0056902 but the real answer is 0.00132705 so clearly something is wrong with my code. THIS IS A MULTINOMIAL PROBABILITY DISTRIBUTION PROBLEM!
say we are given 4 outcome below along with the probabilities
Calculate the probability such that
my attempted code is
% Define the probabilities for each outcome
HH = 0.013;
HL = 0.267;
LH = 0.031;
LL = 0.689;
% Initialize the total probability
totalProbability = 0;
% Loop through possible counts for HL and LH
for nHL = 0:20
for nLH = 0:2
nHH = 0;
nLL = 100 – nHH – nHL – nLH
probability = mnpdf([nHH nHL nLH nLL], [HH HL LH LL])
totalProbability = totalProbability + probability;
end
end
% Display the result
disp([‘The total probability is: ‘, num2str(totalProbability)])
However the code gives the value 0.0056902 but the real answer is 0.00132705 so clearly something is wrong with my code. multinomial probability distribution MATLAB Answers — New Questions
Displaying Text on Paper
I’m printing out something like 400 sheets of paper through MATLAB, and I’d like to be able to display the slice number in the corner of the paper. I’ve attached a preview of what one of the slices will look like. The thing is, the figure doesn’t cover the entire paper; the figure’s only as big as the brain in the center of the paper, so it’s hard to insert text outside the figure. Does anyone have any ideas as to how to put text in the bottom right corner of the paper?I’m printing out something like 400 sheets of paper through MATLAB, and I’d like to be able to display the slice number in the corner of the paper. I’ve attached a preview of what one of the slices will look like. The thing is, the figure doesn’t cover the entire paper; the figure’s only as big as the brain in the center of the paper, so it’s hard to insert text outside the figure. Does anyone have any ideas as to how to put text in the bottom right corner of the paper? I’m printing out something like 400 sheets of paper through MATLAB, and I’d like to be able to display the slice number in the corner of the paper. I’ve attached a preview of what one of the slices will look like. The thing is, the figure doesn’t cover the entire paper; the figure’s only as big as the brain in the center of the paper, so it’s hard to insert text outside the figure. Does anyone have any ideas as to how to put text in the bottom right corner of the paper? print, figure MATLAB Answers — New Questions
“Could not connect to target application: XCP TCP/IP error: Connect failed” during ‘Monitor & Tune’ of ZCU111 RFSoC
Hi,
I’m working through this example* for the Xilinx Zynq UltraScale+ RFSoC ZCU111 Evaluation Kit with MATLAB R2023b. I have Simulink, all of the required toolboxes and Vivado installed allowing me to simulate the design; build the HDL and firmware images; load the base image onto the SD card and onto the RFSoC. However, when I try to Monitor & Tune, running the example on the hardware, I get the following:
Furthermore, if i go into ‘System on Chip’ > ‘Hardware Implementation’ > ‘Target hardware resources’ > ‘External mode’, I cannot specify an IPv4 address or serial port for the XCP server as others have suggested in various other responses:
Serial-ing into the target, all of the files and network config appear correct, so I’m not sure what the issue is:
Any ideas what the issue could be and how to solve it?
Thanks
*Transmit Signal Waveform Using DDR4 on Xilinx RFSoC Device – MATLAB & Simulink – MathWorks United KingdomHi,
I’m working through this example* for the Xilinx Zynq UltraScale+ RFSoC ZCU111 Evaluation Kit with MATLAB R2023b. I have Simulink, all of the required toolboxes and Vivado installed allowing me to simulate the design; build the HDL and firmware images; load the base image onto the SD card and onto the RFSoC. However, when I try to Monitor & Tune, running the example on the hardware, I get the following:
Furthermore, if i go into ‘System on Chip’ > ‘Hardware Implementation’ > ‘Target hardware resources’ > ‘External mode’, I cannot specify an IPv4 address or serial port for the XCP server as others have suggested in various other responses:
Serial-ing into the target, all of the files and network config appear correct, so I’m not sure what the issue is:
Any ideas what the issue could be and how to solve it?
Thanks
*Transmit Signal Waveform Using DDR4 on Xilinx RFSoC Device – MATLAB & Simulink – MathWorks United Kingdom Hi,
I’m working through this example* for the Xilinx Zynq UltraScale+ RFSoC ZCU111 Evaluation Kit with MATLAB R2023b. I have Simulink, all of the required toolboxes and Vivado installed allowing me to simulate the design; build the HDL and firmware images; load the base image onto the SD card and onto the RFSoC. However, when I try to Monitor & Tune, running the example on the hardware, I get the following:
Furthermore, if i go into ‘System on Chip’ > ‘Hardware Implementation’ > ‘Target hardware resources’ > ‘External mode’, I cannot specify an IPv4 address or serial port for the XCP server as others have suggested in various other responses:
Serial-ing into the target, all of the files and network config appear correct, so I’m not sure what the issue is:
Any ideas what the issue could be and how to solve it?
Thanks
*Transmit Signal Waveform Using DDR4 on Xilinx RFSoC Device – MATLAB & Simulink – MathWorks United Kingdom zcu111, rfsoc, simulink, xcp MATLAB Answers — New Questions
how to read a gret scale image in call back function and display it as matrix?
% Callback function for the "Load Image" button
function loadImageCallback(hObject, eventdata, handles)
% Open a file dialog to select an image
[fileName, filePath] = uigetfile({‘*.jpg;*.png;*.bmp;*.tif’, ‘All Image Files’; ‘*.*’, ‘All Files’}, ‘Select an Image’);
% Check if a file was selected
if isequal(fileName, 0)
return; % User canceled the operation
end
% Read the selected image
img = imread(fullfile(filePath, fileName));
% Check if the image was read successfully
if isempty(img)
errordlg(‘Failed to read the image’, ‘Error’);
return;
end
% Store the image data in the handles structure
handles.img = img;
% Update the handles structure
guidata(hObject, handles);
% Optionally, display a message to indicate successful loading
msgbox(‘Image loaded successfully’, ‘Success’);
end% Callback function for the "Load Image" button
function loadImageCallback(hObject, eventdata, handles)
% Open a file dialog to select an image
[fileName, filePath] = uigetfile({‘*.jpg;*.png;*.bmp;*.tif’, ‘All Image Files’; ‘*.*’, ‘All Files’}, ‘Select an Image’);
% Check if a file was selected
if isequal(fileName, 0)
return; % User canceled the operation
end
% Read the selected image
img = imread(fullfile(filePath, fileName));
% Check if the image was read successfully
if isempty(img)
errordlg(‘Failed to read the image’, ‘Error’);
return;
end
% Store the image data in the handles structure
handles.img = img;
% Update the handles structure
guidata(hObject, handles);
% Optionally, display a message to indicate successful loading
msgbox(‘Image loaded successfully’, ‘Success’);
end % Callback function for the "Load Image" button
function loadImageCallback(hObject, eventdata, handles)
% Open a file dialog to select an image
[fileName, filePath] = uigetfile({‘*.jpg;*.png;*.bmp;*.tif’, ‘All Image Files’; ‘*.*’, ‘All Files’}, ‘Select an Image’);
% Check if a file was selected
if isequal(fileName, 0)
return; % User canceled the operation
end
% Read the selected image
img = imread(fullfile(filePath, fileName));
% Check if the image was read successfully
if isempty(img)
errordlg(‘Failed to read the image’, ‘Error’);
return;
end
% Store the image data in the handles structure
handles.img = img;
% Update the handles structure
guidata(hObject, handles);
% Optionally, display a message to indicate successful loading
msgbox(‘Image loaded successfully’, ‘Success’);
end code MATLAB Answers — New Questions
Why I am not getting the same result for an integral of a piecewise function?
I set the following piecewise function to integrate it:
function lambda = weight(x,L1,L2,M)
% L1, L2, M are constants
if x < L1
lambda = (M ./ (4 .* (L1 + L2))) + ((3 .* M) / (2 .* L2 .^ 2)) .* (L1 – x);
else
lambda = M ./ (4 .* (L1 + L2)) .* ones(size(x));
end
end
Now, I am trying to integrate lambda between 0 and 15. Everything looks okay, but the results are different when I try to integrate the whole interval than when I do it by sections. In the following code, check should be 0 or near to 0, but I am getting 5.1042e+03.
lambda = @(x) weight(x,5,10,35000);
aux1 = integral(lambda,0,15)
aux2 = integral(lambda,0,5)
aux3 = integral(lambda,5,15)
check1 = aux1 – aux2 + aux3
Does anyone know what is the issue here?
I know it work fine by sections but I would like it to do it as a whole.I set the following piecewise function to integrate it:
function lambda = weight(x,L1,L2,M)
% L1, L2, M are constants
if x < L1
lambda = (M ./ (4 .* (L1 + L2))) + ((3 .* M) / (2 .* L2 .^ 2)) .* (L1 – x);
else
lambda = M ./ (4 .* (L1 + L2)) .* ones(size(x));
end
end
Now, I am trying to integrate lambda between 0 and 15. Everything looks okay, but the results are different when I try to integrate the whole interval than when I do it by sections. In the following code, check should be 0 or near to 0, but I am getting 5.1042e+03.
lambda = @(x) weight(x,5,10,35000);
aux1 = integral(lambda,0,15)
aux2 = integral(lambda,0,5)
aux3 = integral(lambda,5,15)
check1 = aux1 – aux2 + aux3
Does anyone know what is the issue here?
I know it work fine by sections but I would like it to do it as a whole. I set the following piecewise function to integrate it:
function lambda = weight(x,L1,L2,M)
% L1, L2, M are constants
if x < L1
lambda = (M ./ (4 .* (L1 + L2))) + ((3 .* M) / (2 .* L2 .^ 2)) .* (L1 – x);
else
lambda = M ./ (4 .* (L1 + L2)) .* ones(size(x));
end
end
Now, I am trying to integrate lambda between 0 and 15. Everything looks okay, but the results are different when I try to integrate the whole interval than when I do it by sections. In the following code, check should be 0 or near to 0, but I am getting 5.1042e+03.
lambda = @(x) weight(x,5,10,35000);
aux1 = integral(lambda,0,15)
aux2 = integral(lambda,0,5)
aux3 = integral(lambda,5,15)
check1 = aux1 – aux2 + aux3
Does anyone know what is the issue here?
I know it work fine by sections but I would like it to do it as a whole. integral, piecewise function, function, function handle MATLAB Answers — New Questions
SysIdent Compare: Plot only selected outputs
Hello!
using "compare" from the System Identification Toolbox creates a quick way to compare the created model with the data. But when I use a large model (e.g. with 103 output variables), you cannot see anything in the plot.
% code to plot model comparison with measurement data
compare(id_data, model);
Is there an option to plot only selected outputs using compare?
Thanks,
ChristophHello!
using "compare" from the System Identification Toolbox creates a quick way to compare the created model with the data. But when I use a large model (e.g. with 103 output variables), you cannot see anything in the plot.
% code to plot model comparison with measurement data
compare(id_data, model);
Is there an option to plot only selected outputs using compare?
Thanks,
Christoph Hello!
using "compare" from the System Identification Toolbox creates a quick way to compare the created model with the data. But when I use a large model (e.g. with 103 output variables), you cannot see anything in the plot.
% code to plot model comparison with measurement data
compare(id_data, model);
Is there an option to plot only selected outputs using compare?
Thanks,
Christoph compare, systemidentification, sysident MATLAB Answers — New Questions
how do I store a few seconds of an mp3 stream using matlab.net.http?
I’d like to assign 5 seconds of audio from the following http mp3 stream to a matlab variable using matlab.net.http:
http://radio.garden/api/ara/content/listen/tMGsmGxF/channel.mp3
I’m new to matlab.net.http, so any suggestions would be most welcome.I’d like to assign 5 seconds of audio from the following http mp3 stream to a matlab variable using matlab.net.http:
http://radio.garden/api/ara/content/listen/tMGsmGxF/channel.mp3
I’m new to matlab.net.http, so any suggestions would be most welcome. I’d like to assign 5 seconds of audio from the following http mp3 stream to a matlab variable using matlab.net.http:
http://radio.garden/api/ara/content/listen/tMGsmGxF/channel.mp3
I’m new to matlab.net.http, so any suggestions would be most welcome. matlab.net.http, audio, stream, mp3 MATLAB Answers — New Questions
Change map coordinates to Latex Interpreter
I am making a figure, I want it to use latex interpreter for the axis labels, but I fail at it, maybe because I use the m_map package.
figure
m_proj(‘lambert’,’lon’,[10 20],’lat’,[25 31]);
m_gshhs_c(‘patch’,[.8 .8 .8],’edgecolor’,’none’);
m_grid(‘linewi’,2,’tickdir’,’out’,’fontsize’,24);
I tried using latex interpreter, but it does nothing.
set(gca, ‘TickLabelInterpreter’, ‘latex’);
Any idea what am I missing?I am making a figure, I want it to use latex interpreter for the axis labels, but I fail at it, maybe because I use the m_map package.
figure
m_proj(‘lambert’,’lon’,[10 20],’lat’,[25 31]);
m_gshhs_c(‘patch’,[.8 .8 .8],’edgecolor’,’none’);
m_grid(‘linewi’,2,’tickdir’,’out’,’fontsize’,24);
I tried using latex interpreter, but it does nothing.
set(gca, ‘TickLabelInterpreter’, ‘latex’);
Any idea what am I missing? I am making a figure, I want it to use latex interpreter for the axis labels, but I fail at it, maybe because I use the m_map package.
figure
m_proj(‘lambert’,’lon’,[10 20],’lat’,[25 31]);
m_gshhs_c(‘patch’,[.8 .8 .8],’edgecolor’,’none’);
m_grid(‘linewi’,2,’tickdir’,’out’,’fontsize’,24);
I tried using latex interpreter, but it does nothing.
set(gca, ‘TickLabelInterpreter’, ‘latex’);
Any idea what am I missing? plotting, latex MATLAB Answers — New Questions
Selecting a point on a scatter plot, saving index of point
What is the best way to allow a user to select 5 data points on a scatter plot and then save the index of these plots?
Code I am currently using:
disp(‘Following the trajectory from <start> to <end>, please click 5 points on the plot where you think the keypress moments are, press Enter to confirm’);
% Save points selected on plot by user
[user_selected_keypressframes] = ginput;
% Extract coordinates for each user selected point and save
[uskf1] = user_selected_keypressframes(1,:);
[uskf2] = user_selected_keypressframes(2,:);
[uskf3] = user_selected_keypressframes(3,:);
[uskf4] = user_selected_keypressframes(4,:);
[uskf5] = user_selected_keypressframes(5,:);
Issue:
This code allows the user to click/select any area within the plot, I want them to only be able to click/select data points so I can save the index of these points.What is the best way to allow a user to select 5 data points on a scatter plot and then save the index of these plots?
Code I am currently using:
disp(‘Following the trajectory from <start> to <end>, please click 5 points on the plot where you think the keypress moments are, press Enter to confirm’);
% Save points selected on plot by user
[user_selected_keypressframes] = ginput;
% Extract coordinates for each user selected point and save
[uskf1] = user_selected_keypressframes(1,:);
[uskf2] = user_selected_keypressframes(2,:);
[uskf3] = user_selected_keypressframes(3,:);
[uskf4] = user_selected_keypressframes(4,:);
[uskf5] = user_selected_keypressframes(5,:);
Issue:
This code allows the user to click/select any area within the plot, I want them to only be able to click/select data points so I can save the index of these points. What is the best way to allow a user to select 5 data points on a scatter plot and then save the index of these plots?
Code I am currently using:
disp(‘Following the trajectory from <start> to <end>, please click 5 points on the plot where you think the keypress moments are, press Enter to confirm’);
% Save points selected on plot by user
[user_selected_keypressframes] = ginput;
% Extract coordinates for each user selected point and save
[uskf1] = user_selected_keypressframes(1,:);
[uskf2] = user_selected_keypressframes(2,:);
[uskf3] = user_selected_keypressframes(3,:);
[uskf4] = user_selected_keypressframes(4,:);
[uskf5] = user_selected_keypressframes(5,:);
Issue:
This code allows the user to click/select any area within the plot, I want them to only be able to click/select data points so I can save the index of these points. selecting points MATLAB Answers — New Questions
Why do I receive License Manager Error -139?
Why do I receive License Manager Error -139?Why do I receive License Manager Error -139? Why do I receive License Manager Error -139? MATLAB Answers — New Questions
Simpson integral – problem with writing the formula
I have the following task to do:
I developed the following code:
function I = simpson(f,a,b,n)
%I = SIMPSON(f,a,b,n) przybliża wartość całki funkcji f
%na przedziale [a,b] stosując metodę Simpsona z n podprzedziałami
x = linspace(a, b, n+1); % Określ listę wektor punktów przy użyciu LINSPACE
Delta = (b – a) / n; % Określ stałą Delta
% Zakładamy wstępną wartość całki jako 0, a następnie obliczamy sumę
I = 0;
for i = 1:n % Ustaw zakres dla i w pętli
dI = f(a(i)) + 4 * f(a(i) + a(i+1) / 2) + f(a(i+1)); % Określ składnik sumy dla i-tego podprzedziału
% Zwiększa sumę całkowitą o nową wartość
I = I + dI;
end
% Mnoży sumę przez Delta
I = Delta*I;
end
Auxiliary function:
% Test 1
a = 0; b = 1; n = 10; f = @(x)1-x+x.^3;
I = simpson(f,a,b,n)
fprintf(‘Test1: Błąd trapezów: %e | Błąd Simpsona: %e’,abs(trapz((b-a)/n,f(linspace(a,b,n+1)))-0.75),abs(I-0.75))
% Test 2
a = 0; b = pi/2; n = 50; f = @(x)sin(x);
I = simpson(f,a,b,n)
fprintf(‘Test2: Błąd trapezów: %e | Błąd Simpsona: %e’,abs(trapz((b-a)/n,f(linspace(a,b,n+1)))-1),abs(I-1))
Error message:
Where is the problem?I have the following task to do:
I developed the following code:
function I = simpson(f,a,b,n)
%I = SIMPSON(f,a,b,n) przybliża wartość całki funkcji f
%na przedziale [a,b] stosując metodę Simpsona z n podprzedziałami
x = linspace(a, b, n+1); % Określ listę wektor punktów przy użyciu LINSPACE
Delta = (b – a) / n; % Określ stałą Delta
% Zakładamy wstępną wartość całki jako 0, a następnie obliczamy sumę
I = 0;
for i = 1:n % Ustaw zakres dla i w pętli
dI = f(a(i)) + 4 * f(a(i) + a(i+1) / 2) + f(a(i+1)); % Określ składnik sumy dla i-tego podprzedziału
% Zwiększa sumę całkowitą o nową wartość
I = I + dI;
end
% Mnoży sumę przez Delta
I = Delta*I;
end
Auxiliary function:
% Test 1
a = 0; b = 1; n = 10; f = @(x)1-x+x.^3;
I = simpson(f,a,b,n)
fprintf(‘Test1: Błąd trapezów: %e | Błąd Simpsona: %e’,abs(trapz((b-a)/n,f(linspace(a,b,n+1)))-0.75),abs(I-0.75))
% Test 2
a = 0; b = pi/2; n = 50; f = @(x)sin(x);
I = simpson(f,a,b,n)
fprintf(‘Test2: Błąd trapezów: %e | Błąd Simpsona: %e’,abs(trapz((b-a)/n,f(linspace(a,b,n+1)))-1),abs(I-1))
Error message:
Where is the problem? I have the following task to do:
I developed the following code:
function I = simpson(f,a,b,n)
%I = SIMPSON(f,a,b,n) przybliża wartość całki funkcji f
%na przedziale [a,b] stosując metodę Simpsona z n podprzedziałami
x = linspace(a, b, n+1); % Określ listę wektor punktów przy użyciu LINSPACE
Delta = (b – a) / n; % Określ stałą Delta
% Zakładamy wstępną wartość całki jako 0, a następnie obliczamy sumę
I = 0;
for i = 1:n % Ustaw zakres dla i w pętli
dI = f(a(i)) + 4 * f(a(i) + a(i+1) / 2) + f(a(i+1)); % Określ składnik sumy dla i-tego podprzedziału
% Zwiększa sumę całkowitą o nową wartość
I = I + dI;
end
% Mnoży sumę przez Delta
I = Delta*I;
end
Auxiliary function:
% Test 1
a = 0; b = 1; n = 10; f = @(x)1-x+x.^3;
I = simpson(f,a,b,n)
fprintf(‘Test1: Błąd trapezów: %e | Błąd Simpsona: %e’,abs(trapz((b-a)/n,f(linspace(a,b,n+1)))-0.75),abs(I-0.75))
% Test 2
a = 0; b = pi/2; n = 50; f = @(x)sin(x);
I = simpson(f,a,b,n)
fprintf(‘Test2: Błąd trapezów: %e | Błąd Simpsona: %e’,abs(trapz((b-a)/n,f(linspace(a,b,n+1)))-1),abs(I-1))
Error message:
Where is the problem? #simpson integral MATLAB Answers — New Questions
code gen support for disparitySGM
I noted under Extended Capablities section of the disparitySGM help page, the following code generation limitations are listed:
The name-value pair arguments, ‘DisparityRange’ and ‘UniquenessThreshold’ must be compile-time constants.
Supports code generation only in generic MATLAB Host Computer target platform.
I am targeting ARM device and I am seeing errors like "Transpose on ND array is not defined." while generating code. Are there alternative solutions?I noted under Extended Capablities section of the disparitySGM help page, the following code generation limitations are listed:
The name-value pair arguments, ‘DisparityRange’ and ‘UniquenessThreshold’ must be compile-time constants.
Supports code generation only in generic MATLAB Host Computer target platform.
I am targeting ARM device and I am seeing errors like "Transpose on ND array is not defined." while generating code. Are there alternative solutions? I noted under Extended Capablities section of the disparitySGM help page, the following code generation limitations are listed:
The name-value pair arguments, ‘DisparityRange’ and ‘UniquenessThreshold’ must be compile-time constants.
Supports code generation only in generic MATLAB Host Computer target platform.
I am targeting ARM device and I am seeing errors like "Transpose on ND array is not defined." while generating code. Are there alternative solutions? code generation, matlab coder, computer vision, disparitysgm MATLAB Answers — New Questions
How programmatically create an array from variable-length vectors?
Hello
I have ~500 .mat files, generated by a separate software, which all contain a structure called s1.a. This structure has variable length for each file, and I don’t know this length until each file is loaded into the workspace. I cannot control the naming of the files nor the naming of the structures ahead of time. Example:
s1.a = [1 3 4 2];
s1.a = [4 6 2 9 0 4];
s1.a = [0 9 5 7 2];
s1.a = [4 8 6 1];
s1.a = [5 7 2 9 4 0 1];
…
s500.a = [3 2 0];
I need to end up with a single structure at the end which concatenates all of the individual s1.a structures:
sFinal.a = [1 3 4 2 4 6 2 9 0 4 0 9 5 7 2 4 8 6 1 5 7 2 9 4 0 1 … 3 2 0];
If all structures had the same length, I can easily write a for loop to load each file and then build the array. But I’m struggling with the variable length aspect of each structure.
One thought I had was to pre-allocate an array with NaNs that is longer than the max length of the s1.a structure (which is 3600), thus "forcing" them to be of the same length by populating the first numel(s1.a) slots, and then once the final structure is built, simply removing all the NaNs. But this seems rather convoluted and not efficient.
Any suggestions?
Thank you!Hello
I have ~500 .mat files, generated by a separate software, which all contain a structure called s1.a. This structure has variable length for each file, and I don’t know this length until each file is loaded into the workspace. I cannot control the naming of the files nor the naming of the structures ahead of time. Example:
s1.a = [1 3 4 2];
s1.a = [4 6 2 9 0 4];
s1.a = [0 9 5 7 2];
s1.a = [4 8 6 1];
s1.a = [5 7 2 9 4 0 1];
…
s500.a = [3 2 0];
I need to end up with a single structure at the end which concatenates all of the individual s1.a structures:
sFinal.a = [1 3 4 2 4 6 2 9 0 4 0 9 5 7 2 4 8 6 1 5 7 2 9 4 0 1 … 3 2 0];
If all structures had the same length, I can easily write a for loop to load each file and then build the array. But I’m struggling with the variable length aspect of each structure.
One thought I had was to pre-allocate an array with NaNs that is longer than the max length of the s1.a structure (which is 3600), thus "forcing" them to be of the same length by populating the first numel(s1.a) slots, and then once the final structure is built, simply removing all the NaNs. But this seems rather convoluted and not efficient.
Any suggestions?
Thank you! Hello
I have ~500 .mat files, generated by a separate software, which all contain a structure called s1.a. This structure has variable length for each file, and I don’t know this length until each file is loaded into the workspace. I cannot control the naming of the files nor the naming of the structures ahead of time. Example:
s1.a = [1 3 4 2];
s1.a = [4 6 2 9 0 4];
s1.a = [0 9 5 7 2];
s1.a = [4 8 6 1];
s1.a = [5 7 2 9 4 0 1];
…
s500.a = [3 2 0];
I need to end up with a single structure at the end which concatenates all of the individual s1.a structures:
sFinal.a = [1 3 4 2 4 6 2 9 0 4 0 9 5 7 2 4 8 6 1 5 7 2 9 4 0 1 … 3 2 0];
If all structures had the same length, I can easily write a for loop to load each file and then build the array. But I’m struggling with the variable length aspect of each structure.
One thought I had was to pre-allocate an array with NaNs that is longer than the max length of the s1.a structure (which is 3600), thus "forcing" them to be of the same length by populating the first numel(s1.a) slots, and then once the final structure is built, simply removing all the NaNs. But this seems rather convoluted and not efficient.
Any suggestions?
Thank you! concatenate, for loop, variable length MATLAB Answers — New Questions