Tag Archives: matlab
what(): Unable to launch the MATLABWindow application during installation
So, I’m running a fresh install of Manjaro Gnome and I’m trying to install matlab. I downloaded the installer, unpacked but when I try to run "bash ./install" it gives me the error:
terminate called after throwing an instance of ‘std::runtime_error’
what(): Unable to launch the MATLABWindow application
Matlab version is R2020a.So, I’m running a fresh install of Manjaro Gnome and I’m trying to install matlab. I downloaded the installer, unpacked but when I try to run "bash ./install" it gives me the error:
terminate called after throwing an instance of ‘std::runtime_error’
what(): Unable to launch the MATLABWindow application
Matlab version is R2020a. So, I’m running a fresh install of Manjaro Gnome and I’m trying to install matlab. I downloaded the installer, unpacked but when I try to run "bash ./install" it gives me the error:
terminate called after throwing an instance of ‘std::runtime_error’
what(): Unable to launch the MATLABWindow application
Matlab version is R2020a. manjaro archlinux runtime_error MATLAB Answers — New Questions
What mex compiler can I use on my Macbook Pro 2017?
I have some software which utilizes a couple mex functions, compiled from .c files. They were compiled on a windows computer and so only work on Windows. I’m updating the software to work on other platforms, so I need to re-compile the c files on my mac to make mex functions that are compatible with mac. To do this, I need a compiler that’s compatible with mac. As far as I can tell, the only compiler I can get for free is Xcode.
However, when I try to install Xcode, I can’t. It is not compatible with anything before MacOS 14. Yet when I try to download MacOS 14 Sonoma, I can’t because it’s not compatible with my computer, only with Macbook Pro 2018 and later.
So my question is, how can I compile .c files into mex functions on my macbook pro 2017? Is there any free compiler out there that will do the job?I have some software which utilizes a couple mex functions, compiled from .c files. They were compiled on a windows computer and so only work on Windows. I’m updating the software to work on other platforms, so I need to re-compile the c files on my mac to make mex functions that are compatible with mac. To do this, I need a compiler that’s compatible with mac. As far as I can tell, the only compiler I can get for free is Xcode.
However, when I try to install Xcode, I can’t. It is not compatible with anything before MacOS 14. Yet when I try to download MacOS 14 Sonoma, I can’t because it’s not compatible with my computer, only with Macbook Pro 2018 and later.
So my question is, how can I compile .c files into mex functions on my macbook pro 2017? Is there any free compiler out there that will do the job? I have some software which utilizes a couple mex functions, compiled from .c files. They were compiled on a windows computer and so only work on Windows. I’m updating the software to work on other platforms, so I need to re-compile the c files on my mac to make mex functions that are compatible with mac. To do this, I need a compiler that’s compatible with mac. As far as I can tell, the only compiler I can get for free is Xcode.
However, when I try to install Xcode, I can’t. It is not compatible with anything before MacOS 14. Yet when I try to download MacOS 14 Sonoma, I can’t because it’s not compatible with my computer, only with Macbook Pro 2018 and later.
So my question is, how can I compile .c files into mex functions on my macbook pro 2017? Is there any free compiler out there that will do the job? mex compiler, mex, mac, macbook pro 2017 MATLAB Answers — New Questions
Accurately obtaining the value of a variable at the requested points
Dear all
I am attaching a data set, where the first and second columns represent spatial coordinates (x,y) in two-dimensional space, while the third column shows the value of a given magnitude at the aforementioned set of (x,y) points. I was wondering which could be the best option in a scenario inside a for loop, where the (x,y) variables change at each step, to obtain an accurate value for the aforementioned variable defined in the third column of the attached file, even if for that combination of (x,y) coordinates the value of the variable is not present a priori. Would be something like
griddata(file(:,1),file(:,2),file(:,3),x,y,"cubic");
a quick and accurate approach?Dear all
I am attaching a data set, where the first and second columns represent spatial coordinates (x,y) in two-dimensional space, while the third column shows the value of a given magnitude at the aforementioned set of (x,y) points. I was wondering which could be the best option in a scenario inside a for loop, where the (x,y) variables change at each step, to obtain an accurate value for the aforementioned variable defined in the third column of the attached file, even if for that combination of (x,y) coordinates the value of the variable is not present a priori. Would be something like
griddata(file(:,1),file(:,2),file(:,3),x,y,"cubic");
a quick and accurate approach? Dear all
I am attaching a data set, where the first and second columns represent spatial coordinates (x,y) in two-dimensional space, while the third column shows the value of a given magnitude at the aforementioned set of (x,y) points. I was wondering which could be the best option in a scenario inside a for loop, where the (x,y) variables change at each step, to obtain an accurate value for the aforementioned variable defined in the third column of the attached file, even if for that combination of (x,y) coordinates the value of the variable is not present a priori. Would be something like
griddata(file(:,1),file(:,2),file(:,3),x,y,"cubic");
a quick and accurate approach? guessing data at a given set of points MATLAB Answers — New Questions
No puedo instalar matlab R2020a, me sale un error del uninstaller200_win65.zip
No puedo instalar el matlab, lo he intentado varias veces, pero siempre me salta el mismo error de que no encuentra el uninstaller200_win64.zipNo puedo instalar el matlab, lo he intentado varias veces, pero siempre me salta el mismo error de que no encuentra el uninstaller200_win64.zip No puedo instalar el matlab, lo he intentado varias veces, pero siempre me salta el mismo error de que no encuentra el uninstaller200_win64.zip error, installation, matlab MATLAB Answers — New Questions
double and triple integral for a complex function. I coded but did not get any output
f = (-1) * (x + l/2) ./ ((x + l/2).^2 + (y – y1).^2 + (z – z1).^2).^(3/2);
The goal is to do the double integral of that function over dy1 and dz1 and then the next step is to do the triple integral of the result(double integration result) over dx,dy and dz. I tried these in several ways but it looks like Matlab is unable to to this integration. Any suggestion?f = (-1) * (x + l/2) ./ ((x + l/2).^2 + (y – y1).^2 + (z – z1).^2).^(3/2);
The goal is to do the double integral of that function over dy1 and dz1 and then the next step is to do the triple integral of the result(double integration result) over dx,dy and dz. I tried these in several ways but it looks like Matlab is unable to to this integration. Any suggestion? f = (-1) * (x + l/2) ./ ((x + l/2).^2 + (y – y1).^2 + (z – z1).^2).^(3/2);
The goal is to do the double integral of that function over dy1 and dz1 and then the next step is to do the triple integral of the result(double integration result) over dx,dy and dz. I tried these in several ways but it looks like Matlab is unable to to this integration. Any suggestion? doble integration, matlab MATLAB Answers — New Questions
Changing sample time of multiple blocks at once
Hi, I have a subsystem with many many blocks and I want to change all their sample times from 1 to -1. I was wondering if there’s any shortcut to do this?Hi, I have a subsystem with many many blocks and I want to change all their sample times from 1 to -1. I was wondering if there’s any shortcut to do this? Hi, I have a subsystem with many many blocks and I want to change all their sample times from 1 to -1. I was wondering if there’s any shortcut to do this? simulink, sample time MATLAB Answers — New Questions
Matlab inherited environment when launched from command window
It has been my experience that Matlab inherits the dos environment when launched from a command window (or powershell).
e.g. open Command Prompt
c:UsersFoo> matlab
This does in fact work on 2 laptops Win10 and Win11. On a 3rd Win11 laptop however it does not seem to work. I did some workarounds within Matlab to get past that but I also found when I execute dos .bat from Matlab on that 3rd laptop, The dos window opened does not have the env from the original that I used to launch Matlab.
Is there a workaround? My searches came up dry.It has been my experience that Matlab inherits the dos environment when launched from a command window (or powershell).
e.g. open Command Prompt
c:UsersFoo> matlab
This does in fact work on 2 laptops Win10 and Win11. On a 3rd Win11 laptop however it does not seem to work. I did some workarounds within Matlab to get past that but I also found when I execute dos .bat from Matlab on that 3rd laptop, The dos window opened does not have the env from the original that I used to launch Matlab.
Is there a workaround? My searches came up dry. It has been my experience that Matlab inherits the dos environment when launched from a command window (or powershell).
e.g. open Command Prompt
c:UsersFoo> matlab
This does in fact work on 2 laptops Win10 and Win11. On a 3rd Win11 laptop however it does not seem to work. I did some workarounds within Matlab to get past that but I also found when I execute dos .bat from Matlab on that 3rd laptop, The dos window opened does not have the env from the original that I used to launch Matlab.
Is there a workaround? My searches came up dry. dos, environment, matlab MATLAB Answers — New Questions
How to creat grouped violin plot?
Hi, how can I create a grouped violin plot like this? I have tried different violin plot function such as GitHub – bastibe/Violinplot-Matlab: Violin Plots for Matlab. But I cannot find a way to create violin plot that is grouped by their categoery. The example figure is created in Seaborn-python. But I am not very familiar with python so I can only create the figure with default setting. It will be great if somebody can help me to create it in Matlab! :)Hi, how can I create a grouped violin plot like this? I have tried different violin plot function such as GitHub – bastibe/Violinplot-Matlab: Violin Plots for Matlab. But I cannot find a way to create violin plot that is grouped by their categoery. The example figure is created in Seaborn-python. But I am not very familiar with python so I can only create the figure with default setting. It will be great if somebody can help me to create it in Matlab! 🙂 Hi, how can I create a grouped violin plot like this? I have tried different violin plot function such as GitHub – bastibe/Violinplot-Matlab: Violin Plots for Matlab. But I cannot find a way to create violin plot that is grouped by their categoery. The example figure is created in Seaborn-python. But I am not very familiar with python so I can only create the figure with default setting. It will be great if somebody can help me to create it in Matlab! 🙂 violin plot, grouped by categoery MATLAB Answers — New Questions
ncorr post CS tool fail
Hi,
I have been doing research at UNSW in Australia. I have been using the ncorr in my research work for image processing. However, in the step of image processing, the ncorr_post CS tool is not working. Every time, it gives me the below error. Could you please let me know the reason of this problem and how to sort it this problem?Hi,
I have been doing research at UNSW in Australia. I have been using the ncorr in my research work for image processing. However, in the step of image processing, the ncorr_post CS tool is not working. Every time, it gives me the below error. Could you please let me know the reason of this problem and how to sort it this problem? Hi,
I have been doing research at UNSW in Australia. I have been using the ncorr in my research work for image processing. However, in the step of image processing, the ncorr_post CS tool is not working. Every time, it gives me the below error. Could you please let me know the reason of this problem and how to sort it this problem? ncorr, matlab MATLAB Answers — New Questions
Reaction wheel in SimMechanics
How to create a reaction relationship between two bodies in SimMechanics?
Task: transferring torque from a reaction wheel to the body it is attached to.
Problem: the wheel rotates, but the body does not move, the torque is not transferred.
Software used: transferring a model from SolidWorks to SimMechanics.How to create a reaction relationship between two bodies in SimMechanics?
Task: transferring torque from a reaction wheel to the body it is attached to.
Problem: the wheel rotates, but the body does not move, the torque is not transferred.
Software used: transferring a model from SolidWorks to SimMechanics. How to create a reaction relationship between two bodies in SimMechanics?
Task: transferring torque from a reaction wheel to the body it is attached to.
Problem: the wheel rotates, but the body does not move, the torque is not transferred.
Software used: transferring a model from SolidWorks to SimMechanics. simmechanics, solidworks, simulink MATLAB Answers — New Questions
Code still functioning according to lines of code I have deleted
I’m trying to make a text box that the user can type into, which then retreives and prints that text when the user clicks enter. Two days ago it was working perfectly. Yesterday it stopped working properly. It prints the currently held text AND THEN updates with the what the user has input. So if I type in "bob" and click enter, nothing displays. If I delete "bob" and type in "peter", and click enter, it displays bob. Click enter again, and it displays "peter".
It got to the point that I just deleted the code and tried to start over. FOR SOME REASON, it still acts exactly the same, updating the text only when I click enter, despite the fact that I have no lines of code that refer to the enter key.
This is what I have right now:
function codeComponentResponse
fig = uifigure(‘position’,[2 50 637 641]);
TextArea = uieditfield(fig, ‘Position’,[100 100 500 30]);
fig.WindowKeyPressFcn = {@CoolGuy, fig, TextArea};
function CoolGuy(src, event, figure, field)
text = field.Value;
disp(text)
end
endI’m trying to make a text box that the user can type into, which then retreives and prints that text when the user clicks enter. Two days ago it was working perfectly. Yesterday it stopped working properly. It prints the currently held text AND THEN updates with the what the user has input. So if I type in "bob" and click enter, nothing displays. If I delete "bob" and type in "peter", and click enter, it displays bob. Click enter again, and it displays "peter".
It got to the point that I just deleted the code and tried to start over. FOR SOME REASON, it still acts exactly the same, updating the text only when I click enter, despite the fact that I have no lines of code that refer to the enter key.
This is what I have right now:
function codeComponentResponse
fig = uifigure(‘position’,[2 50 637 641]);
TextArea = uieditfield(fig, ‘Position’,[100 100 500 30]);
fig.WindowKeyPressFcn = {@CoolGuy, fig, TextArea};
function CoolGuy(src, event, figure, field)
text = field.Value;
disp(text)
end
end I’m trying to make a text box that the user can type into, which then retreives and prints that text when the user clicks enter. Two days ago it was working perfectly. Yesterday it stopped working properly. It prints the currently held text AND THEN updates with the what the user has input. So if I type in "bob" and click enter, nothing displays. If I delete "bob" and type in "peter", and click enter, it displays bob. Click enter again, and it displays "peter".
It got to the point that I just deleted the code and tried to start over. FOR SOME REASON, it still acts exactly the same, updating the text only when I click enter, despite the fact that I have no lines of code that refer to the enter key.
This is what I have right now:
function codeComponentResponse
fig = uifigure(‘position’,[2 50 637 641]);
TextArea = uieditfield(fig, ‘Position’,[100 100 500 30]);
fig.WindowKeyPressFcn = {@CoolGuy, fig, TextArea};
function CoolGuy(src, event, figure, field)
text = field.Value;
disp(text)
end
end uifigure, uieditfield, callback, text field MATLAB Answers — New Questions
How to interpolate at NaN values?
I have a vector [1 2 3 NaN 4 4.5 5.5 NaN NaN 6 6 7 NaN NaN NaN 8] and I want [1 2 3 3.5 4 4.5 5.5 5.75 5.75 6 6 7 7.5 7.5 7.5 8]. Is it possible to do this without a for cycle?I have a vector [1 2 3 NaN 4 4.5 5.5 NaN NaN 6 6 7 NaN NaN NaN 8] and I want [1 2 3 3.5 4 4.5 5.5 5.75 5.75 6 6 7 7.5 7.5 7.5 8]. Is it possible to do this without a for cycle? I have a vector [1 2 3 NaN 4 4.5 5.5 NaN NaN 6 6 7 NaN NaN NaN 8] and I want [1 2 3 3.5 4 4.5 5.5 5.75 5.75 6 6 7 7.5 7.5 7.5 8]. Is it possible to do this without a for cycle? for, vector, nan, interpolation MATLAB Answers — New Questions
Solving Eigenvalues of a system time-varying which is 5×5 matrix
I am trying to solve this system by using a desired eigenvalues to be equated to the det(SI-A) ,so every thing in that matrix is know except Lambda’s , I decoupled the problem by making eta_tilde=0 and then e =0 and I managed to obtain L and it was easier to get L in that way ,but the problem now is to obtain lambda that makes this matrix aysmptoically stable , SINCE it is linear time-varying w.r.t the error so according to lypunov it is better to check the stablity of (A^T+A) to place the eigenvalues to zero, it is complex to solve manually ,so I used the matlab to get the det(SI-A) symbolically ,but how to solve for lambda’s.I am trying to solve this system by using a desired eigenvalues to be equated to the det(SI-A) ,so every thing in that matrix is know except Lambda’s , I decoupled the problem by making eta_tilde=0 and then e =0 and I managed to obtain L and it was easier to get L in that way ,but the problem now is to obtain lambda that makes this matrix aysmptoically stable , SINCE it is linear time-varying w.r.t the error so according to lypunov it is better to check the stablity of (A^T+A) to place the eigenvalues to zero, it is complex to solve manually ,so I used the matlab to get the det(SI-A) symbolically ,but how to solve for lambda’s. I am trying to solve this system by using a desired eigenvalues to be equated to the det(SI-A) ,so every thing in that matrix is know except Lambda’s , I decoupled the problem by making eta_tilde=0 and then e =0 and I managed to obtain L and it was easier to get L in that way ,but the problem now is to obtain lambda that makes this matrix aysmptoically stable , SINCE it is linear time-varying w.r.t the error so according to lypunov it is better to check the stablity of (A^T+A) to place the eigenvalues to zero, it is complex to solve manually ,so I used the matlab to get the det(SI-A) symbolically ,but how to solve for lambda’s. #eigenvalues #stablity #ltv MATLAB Answers — New Questions
Filling a shape with Geoplot
I am creating a polygon using coordinate points with geoplot, and I would like to fill the resultant shape in a partially transparent blue color. I am able to create the filled shape, and I can overlay the outline on the map with geoplot, but I cannot do both.
%% Plot
% Create a figure
figure;
% Create a geographic axes
gx = geoaxes;
hold(gx, ‘on’);
% Define the indices of visible points
visibleIndices = maxRadiusPerAngle > 0;
% Close the loop by adding the first point at the end
latTargetsClosed = [latTargets(visibleIndices) latTargets(visibleIndices(1))];
lonTargetsClosed = [lonTargets(visibleIndices) lonTargets(visibleIndices(1))];
% Plot the outline of the polygon using geoplot
geoplot(gx, latTargetsClosed, lonTargetsClosed, ‘b-‘, ‘LineWidth’, 2);
% Plot the central point
geoplot(gx, latCenter, lonCenter, ‘ro’, ‘MarkerSize’, 8, ‘MarkerFaceColor’, ‘r’);
% Plot the visible points
geoplot(gx, latTargets(visibleIndices), lonTargets(visibleIndices), ‘go’, ‘MarkerSize’, 6, ‘MarkerFaceColor’, ‘g’);
% Set the basemap
geobasemap(gx, ‘streets’);
title(‘Furthest Outward Points with Positive LOS’);
% Define the Web Mercator projection
projCRS = projcrs(3857); % EPSG:3857 Web Mercator
% Convert geographic coordinates to projected coordinates
[x, y] = projfwd(projCRS, latTargetsClosed, lonTargetsClosed);
% Create a new Cartesian plot for the filled polygon, ensuring it overlays the geographic axes
figure;
hold on;
% Create a filled polygon in the Cartesian plot
fill(x, y, ‘b’, ‘FaceAlpha’, 0.3, ‘EdgeColor’, ‘none’);
% Set Cartesian axes limits to match the geographic plot
axis equal;
xlabel(‘X (meters)’);
ylabel(‘Y (meters)’);
title(‘Filled Polygon in Projected Coordinates’);
% Adjust the limits to fit the geographic plot
latlim = gx.LatitudeLimits;
lonlim = gx.LongitudeLimits;
[xlim, ylim] = projfwd(projCRS, [latlim(1), latlim(2)], [lonlim(1), lonlim(2)]);
set(gca, ‘XLim’, xlim, ‘YLim’, ylim);
% Ensure the Cartesian plot is visible
set(gcf, ‘Visible’, ‘on’);I am creating a polygon using coordinate points with geoplot, and I would like to fill the resultant shape in a partially transparent blue color. I am able to create the filled shape, and I can overlay the outline on the map with geoplot, but I cannot do both.
%% Plot
% Create a figure
figure;
% Create a geographic axes
gx = geoaxes;
hold(gx, ‘on’);
% Define the indices of visible points
visibleIndices = maxRadiusPerAngle > 0;
% Close the loop by adding the first point at the end
latTargetsClosed = [latTargets(visibleIndices) latTargets(visibleIndices(1))];
lonTargetsClosed = [lonTargets(visibleIndices) lonTargets(visibleIndices(1))];
% Plot the outline of the polygon using geoplot
geoplot(gx, latTargetsClosed, lonTargetsClosed, ‘b-‘, ‘LineWidth’, 2);
% Plot the central point
geoplot(gx, latCenter, lonCenter, ‘ro’, ‘MarkerSize’, 8, ‘MarkerFaceColor’, ‘r’);
% Plot the visible points
geoplot(gx, latTargets(visibleIndices), lonTargets(visibleIndices), ‘go’, ‘MarkerSize’, 6, ‘MarkerFaceColor’, ‘g’);
% Set the basemap
geobasemap(gx, ‘streets’);
title(‘Furthest Outward Points with Positive LOS’);
% Define the Web Mercator projection
projCRS = projcrs(3857); % EPSG:3857 Web Mercator
% Convert geographic coordinates to projected coordinates
[x, y] = projfwd(projCRS, latTargetsClosed, lonTargetsClosed);
% Create a new Cartesian plot for the filled polygon, ensuring it overlays the geographic axes
figure;
hold on;
% Create a filled polygon in the Cartesian plot
fill(x, y, ‘b’, ‘FaceAlpha’, 0.3, ‘EdgeColor’, ‘none’);
% Set Cartesian axes limits to match the geographic plot
axis equal;
xlabel(‘X (meters)’);
ylabel(‘Y (meters)’);
title(‘Filled Polygon in Projected Coordinates’);
% Adjust the limits to fit the geographic plot
latlim = gx.LatitudeLimits;
lonlim = gx.LongitudeLimits;
[xlim, ylim] = projfwd(projCRS, [latlim(1), latlim(2)], [lonlim(1), lonlim(2)]);
set(gca, ‘XLim’, xlim, ‘YLim’, ylim);
% Ensure the Cartesian plot is visible
set(gcf, ‘Visible’, ‘on’); I am creating a polygon using coordinate points with geoplot, and I would like to fill the resultant shape in a partially transparent blue color. I am able to create the filled shape, and I can overlay the outline on the map with geoplot, but I cannot do both.
%% Plot
% Create a figure
figure;
% Create a geographic axes
gx = geoaxes;
hold(gx, ‘on’);
% Define the indices of visible points
visibleIndices = maxRadiusPerAngle > 0;
% Close the loop by adding the first point at the end
latTargetsClosed = [latTargets(visibleIndices) latTargets(visibleIndices(1))];
lonTargetsClosed = [lonTargets(visibleIndices) lonTargets(visibleIndices(1))];
% Plot the outline of the polygon using geoplot
geoplot(gx, latTargetsClosed, lonTargetsClosed, ‘b-‘, ‘LineWidth’, 2);
% Plot the central point
geoplot(gx, latCenter, lonCenter, ‘ro’, ‘MarkerSize’, 8, ‘MarkerFaceColor’, ‘r’);
% Plot the visible points
geoplot(gx, latTargets(visibleIndices), lonTargets(visibleIndices), ‘go’, ‘MarkerSize’, 6, ‘MarkerFaceColor’, ‘g’);
% Set the basemap
geobasemap(gx, ‘streets’);
title(‘Furthest Outward Points with Positive LOS’);
% Define the Web Mercator projection
projCRS = projcrs(3857); % EPSG:3857 Web Mercator
% Convert geographic coordinates to projected coordinates
[x, y] = projfwd(projCRS, latTargetsClosed, lonTargetsClosed);
% Create a new Cartesian plot for the filled polygon, ensuring it overlays the geographic axes
figure;
hold on;
% Create a filled polygon in the Cartesian plot
fill(x, y, ‘b’, ‘FaceAlpha’, 0.3, ‘EdgeColor’, ‘none’);
% Set Cartesian axes limits to match the geographic plot
axis equal;
xlabel(‘X (meters)’);
ylabel(‘Y (meters)’);
title(‘Filled Polygon in Projected Coordinates’);
% Adjust the limits to fit the geographic plot
latlim = gx.LatitudeLimits;
lonlim = gx.LongitudeLimits;
[xlim, ylim] = projfwd(projCRS, [latlim(1), latlim(2)], [lonlim(1), lonlim(2)]);
set(gca, ‘XLim’, xlim, ‘YLim’, ylim);
% Ensure the Cartesian plot is visible
set(gcf, ‘Visible’, ‘on’); geoplot, mapping toolbox MATLAB Answers — New Questions
lsqcurvefit issues due to variables being several orders of magnitude different
I am trying to use lsqcurvefit to fit an equation to some data in order to solve for a couple variables. I have included the part of the code below that covers this. I am trying to solve for coeff(1) and coeff(2), The problem is that when I run lsqcurvefit, it is just using whatever my initial guesses are and outputting that as the solution. I suspect it is because my values for the coefficients will be several orders of magnitude different. You can kind of get an idea for this by looking at coeff0. Has anyone else run into this problem and/or do you know how to work around it? Any insight would be greatly appreciated.
load(‘V1.mat’)
load(‘Vp.mat’)
load(‘data.mat’)
V = [V1, Vp]; %voltages
a = 1.1792;
b = 0.5;
e = 1.60217662e-19;
Area = 4.7909e-7;
mi = 39.948./(6.022e23.*1000);
coeff0 = [7e10 4]; %initial guess
Eqn7 = @(coeff, VV) e^1.5*coeff(1)*Area*sqrt(coeff(2)/(2*pi*mi))*100^3*… (a*(-VV(:,1)/coeff(2)).^b.*tanh(VV(:,2)/(2*coeff(2))) + …
(a*(-VV(:,1)/coeff(2)).^b – a*(-(VV(:,1)+VV(:,2))/coeff(2)).^b)./(exp(VV(:,2)/coeff(2))+1);
options = optimoptions(‘lsqcurvefit’,’Algorithm’,’levenberg-marquardt’,’OptimalityTolerance’,1e-16,’FunctionTolerance’,1e-16);
lb = [];
ub = [];
[vals, resnorm, out, flag] = lsqcurvefit(Eqn7, coeff0, V, data(:,2),lb,ub);
plot(data(:,1),data(:,2),’x’,data(:,1),Eqn7(vals,V),’b-‘)I am trying to use lsqcurvefit to fit an equation to some data in order to solve for a couple variables. I have included the part of the code below that covers this. I am trying to solve for coeff(1) and coeff(2), The problem is that when I run lsqcurvefit, it is just using whatever my initial guesses are and outputting that as the solution. I suspect it is because my values for the coefficients will be several orders of magnitude different. You can kind of get an idea for this by looking at coeff0. Has anyone else run into this problem and/or do you know how to work around it? Any insight would be greatly appreciated.
load(‘V1.mat’)
load(‘Vp.mat’)
load(‘data.mat’)
V = [V1, Vp]; %voltages
a = 1.1792;
b = 0.5;
e = 1.60217662e-19;
Area = 4.7909e-7;
mi = 39.948./(6.022e23.*1000);
coeff0 = [7e10 4]; %initial guess
Eqn7 = @(coeff, VV) e^1.5*coeff(1)*Area*sqrt(coeff(2)/(2*pi*mi))*100^3*… (a*(-VV(:,1)/coeff(2)).^b.*tanh(VV(:,2)/(2*coeff(2))) + …
(a*(-VV(:,1)/coeff(2)).^b – a*(-(VV(:,1)+VV(:,2))/coeff(2)).^b)./(exp(VV(:,2)/coeff(2))+1);
options = optimoptions(‘lsqcurvefit’,’Algorithm’,’levenberg-marquardt’,’OptimalityTolerance’,1e-16,’FunctionTolerance’,1e-16);
lb = [];
ub = [];
[vals, resnorm, out, flag] = lsqcurvefit(Eqn7, coeff0, V, data(:,2),lb,ub);
plot(data(:,1),data(:,2),’x’,data(:,1),Eqn7(vals,V),’b-‘) I am trying to use lsqcurvefit to fit an equation to some data in order to solve for a couple variables. I have included the part of the code below that covers this. I am trying to solve for coeff(1) and coeff(2), The problem is that when I run lsqcurvefit, it is just using whatever my initial guesses are and outputting that as the solution. I suspect it is because my values for the coefficients will be several orders of magnitude different. You can kind of get an idea for this by looking at coeff0. Has anyone else run into this problem and/or do you know how to work around it? Any insight would be greatly appreciated.
load(‘V1.mat’)
load(‘Vp.mat’)
load(‘data.mat’)
V = [V1, Vp]; %voltages
a = 1.1792;
b = 0.5;
e = 1.60217662e-19;
Area = 4.7909e-7;
mi = 39.948./(6.022e23.*1000);
coeff0 = [7e10 4]; %initial guess
Eqn7 = @(coeff, VV) e^1.5*coeff(1)*Area*sqrt(coeff(2)/(2*pi*mi))*100^3*… (a*(-VV(:,1)/coeff(2)).^b.*tanh(VV(:,2)/(2*coeff(2))) + …
(a*(-VV(:,1)/coeff(2)).^b – a*(-(VV(:,1)+VV(:,2))/coeff(2)).^b)./(exp(VV(:,2)/coeff(2))+1);
options = optimoptions(‘lsqcurvefit’,’Algorithm’,’levenberg-marquardt’,’OptimalityTolerance’,1e-16,’FunctionTolerance’,1e-16);
lb = [];
ub = [];
[vals, resnorm, out, flag] = lsqcurvefit(Eqn7, coeff0, V, data(:,2),lb,ub);
plot(data(:,1),data(:,2),’x’,data(:,1),Eqn7(vals,V),’b-‘) curve fitting MATLAB Answers — New Questions
Unable to draw the given inter-satellite path.
I wrote a Python script and got a path selection at a certain point as [‘Satellite_185’, ‘Satellite_113’, ‘Satellite_162’, ‘Satellite_108’, ‘Satellite_87’, ‘Satellite_68’, ‘Satellite_305’, ‘Satellite_335’, ‘Satellite_384’]. Then I wrote the following MATLAB code, but it gets stuck at the simulation scene step. I suspect it’s because of the time issue, but I can’t fix it.
% Create Satellite Scenario
startTime = datetime(2021,12,10,18,27,57); % 10 December 2021, 6:27:57 PM UTC
stopTime = startTime + hours(3); % 10 December 2021, 9:27:57 PM UTC
sampleTime = 60; % Seconds
sc = satelliteScenario(startTime,stopTime,sampleTime,"AutoSimulate",false);
% Load the entire constellation, but we’ll only use the specified relay satellites
satellites = satellite(sc,"largeConstellation2.tle");
% Known relay satellite names or identifiers (assuming you have them)
% If you only have indices, you’ll need to map them to satellite objects somehow
% Here we assume you have the satellite objects directly
% relaySats = {…}; % This should be filled with the actual satellite objects
% Example: relaySats = {satellites(10), satellites(20), satellites(30)};
% But since you likely have names or other identifiers, you’ll need to find them
% Or, if you have indices into the ‘satellites’ array
relaySatsIndices = [185, 113, 162, 108, 87, 68, 305, 335, 384]; % Example indices
relaySats = satellites(relaySatsIndices);
% Add Ground Stations
gsSource = groundStation(sc,42.3001,-71.3504, "Name","Source Ground Station");
gsTarget = groundStation(sc,17.4351,78.3824, "Name","Target Ground Station");
% Build the path using the known relay satellite sequence
pathNodes = {gsSource, relaySats, gsTarget};
% Visualize Path
sc.AutoSimulate = true;
ac = access(pathNodes{:});
ac.LineColor = "red";
% Determine Intervals When Calculated Path Can Be Used (if needed)
% intvls = accessIntervals(ac); % Uncomment this line if you need the access intervals
% Create satellite scenario viewer
v = satelliteScenarioViewer(sc,"ShowDetails",false);
% Note: Setting MarkerSize directly on the satellites object may not work as expected.
% Instead, adjust the visualization properties in the viewer or use a loop to set markers.
% Play the scenario
play(sc);
The code above references part of the code from this website:https://www.mathworks.com/help/satcom/ug/multihop-path-select-through-sat-constellation.html
This picture is my stuck interface after running in matlab.I wrote a Python script and got a path selection at a certain point as [‘Satellite_185’, ‘Satellite_113’, ‘Satellite_162’, ‘Satellite_108’, ‘Satellite_87’, ‘Satellite_68’, ‘Satellite_305’, ‘Satellite_335’, ‘Satellite_384’]. Then I wrote the following MATLAB code, but it gets stuck at the simulation scene step. I suspect it’s because of the time issue, but I can’t fix it.
% Create Satellite Scenario
startTime = datetime(2021,12,10,18,27,57); % 10 December 2021, 6:27:57 PM UTC
stopTime = startTime + hours(3); % 10 December 2021, 9:27:57 PM UTC
sampleTime = 60; % Seconds
sc = satelliteScenario(startTime,stopTime,sampleTime,"AutoSimulate",false);
% Load the entire constellation, but we’ll only use the specified relay satellites
satellites = satellite(sc,"largeConstellation2.tle");
% Known relay satellite names or identifiers (assuming you have them)
% If you only have indices, you’ll need to map them to satellite objects somehow
% Here we assume you have the satellite objects directly
% relaySats = {…}; % This should be filled with the actual satellite objects
% Example: relaySats = {satellites(10), satellites(20), satellites(30)};
% But since you likely have names or other identifiers, you’ll need to find them
% Or, if you have indices into the ‘satellites’ array
relaySatsIndices = [185, 113, 162, 108, 87, 68, 305, 335, 384]; % Example indices
relaySats = satellites(relaySatsIndices);
% Add Ground Stations
gsSource = groundStation(sc,42.3001,-71.3504, "Name","Source Ground Station");
gsTarget = groundStation(sc,17.4351,78.3824, "Name","Target Ground Station");
% Build the path using the known relay satellite sequence
pathNodes = {gsSource, relaySats, gsTarget};
% Visualize Path
sc.AutoSimulate = true;
ac = access(pathNodes{:});
ac.LineColor = "red";
% Determine Intervals When Calculated Path Can Be Used (if needed)
% intvls = accessIntervals(ac); % Uncomment this line if you need the access intervals
% Create satellite scenario viewer
v = satelliteScenarioViewer(sc,"ShowDetails",false);
% Note: Setting MarkerSize directly on the satellites object may not work as expected.
% Instead, adjust the visualization properties in the viewer or use a loop to set markers.
% Play the scenario
play(sc);
The code above references part of the code from this website:https://www.mathworks.com/help/satcom/ug/multihop-path-select-through-sat-constellation.html
This picture is my stuck interface after running in matlab. I wrote a Python script and got a path selection at a certain point as [‘Satellite_185’, ‘Satellite_113’, ‘Satellite_162’, ‘Satellite_108’, ‘Satellite_87’, ‘Satellite_68’, ‘Satellite_305’, ‘Satellite_335’, ‘Satellite_384’]. Then I wrote the following MATLAB code, but it gets stuck at the simulation scene step. I suspect it’s because of the time issue, but I can’t fix it.
% Create Satellite Scenario
startTime = datetime(2021,12,10,18,27,57); % 10 December 2021, 6:27:57 PM UTC
stopTime = startTime + hours(3); % 10 December 2021, 9:27:57 PM UTC
sampleTime = 60; % Seconds
sc = satelliteScenario(startTime,stopTime,sampleTime,"AutoSimulate",false);
% Load the entire constellation, but we’ll only use the specified relay satellites
satellites = satellite(sc,"largeConstellation2.tle");
% Known relay satellite names or identifiers (assuming you have them)
% If you only have indices, you’ll need to map them to satellite objects somehow
% Here we assume you have the satellite objects directly
% relaySats = {…}; % This should be filled with the actual satellite objects
% Example: relaySats = {satellites(10), satellites(20), satellites(30)};
% But since you likely have names or other identifiers, you’ll need to find them
% Or, if you have indices into the ‘satellites’ array
relaySatsIndices = [185, 113, 162, 108, 87, 68, 305, 335, 384]; % Example indices
relaySats = satellites(relaySatsIndices);
% Add Ground Stations
gsSource = groundStation(sc,42.3001,-71.3504, "Name","Source Ground Station");
gsTarget = groundStation(sc,17.4351,78.3824, "Name","Target Ground Station");
% Build the path using the known relay satellite sequence
pathNodes = {gsSource, relaySats, gsTarget};
% Visualize Path
sc.AutoSimulate = true;
ac = access(pathNodes{:});
ac.LineColor = "red";
% Determine Intervals When Calculated Path Can Be Used (if needed)
% intvls = accessIntervals(ac); % Uncomment this line if you need the access intervals
% Create satellite scenario viewer
v = satelliteScenarioViewer(sc,"ShowDetails",false);
% Note: Setting MarkerSize directly on the satellites object may not work as expected.
% Instead, adjust the visualization properties in the viewer or use a loop to set markers.
% Play the scenario
play(sc);
The code above references part of the code from this website:https://www.mathworks.com/help/satcom/ug/multihop-path-select-through-sat-constellation.html
This picture is my stuck interface after running in matlab. large satellite constellation MATLAB Answers — New Questions
Why can’t I use the “Load Application” button in my deployed SLRT app to switch between MLDATX files to run on my Speedgoat target?
I have an App Designer app to interact with a Simulink Real-Time (SLRT) simulation running on my Speedgoat target. When running the app in MATLAB, I can switch between multiple MLDATX real-time application files to run on my Speedgoat using this dialog:
Then, I deployed this app to a standalone executable using MATLAB Compiler. However, when I try to click the "Load Application" button in the standalone app, either nothing happens (no dialog opens), or the following error occurs when attempting to load the MLDATX file:
Dot indexing into the result of a function call requires parentheses after the function name. The supported syntax is ‘sIrealtime().internal’.
Since R2024a:
Error communicating with target ‘xx.xx.xx.xx’: Specify the real-time application name in the ‘Application’ property of the Load Button component in the instrument panel app.
Then, I tried to implement a manual logic in my app using app.tg.load() that switches between MLDATX files of the same name located in different folders. This works when launching the app from MATLAB, but not when it’s deployed.I have an App Designer app to interact with a Simulink Real-Time (SLRT) simulation running on my Speedgoat target. When running the app in MATLAB, I can switch between multiple MLDATX real-time application files to run on my Speedgoat using this dialog:
Then, I deployed this app to a standalone executable using MATLAB Compiler. However, when I try to click the "Load Application" button in the standalone app, either nothing happens (no dialog opens), or the following error occurs when attempting to load the MLDATX file:
Dot indexing into the result of a function call requires parentheses after the function name. The supported syntax is ‘sIrealtime().internal’.
Since R2024a:
Error communicating with target ‘xx.xx.xx.xx’: Specify the real-time application name in the ‘Application’ property of the Load Button component in the instrument panel app.
Then, I tried to implement a manual logic in my app using app.tg.load() that switches between MLDATX files of the same name located in different folders. This works when launching the app from MATLAB, but not when it’s deployed. I have an App Designer app to interact with a Simulink Real-Time (SLRT) simulation running on my Speedgoat target. When running the app in MATLAB, I can switch between multiple MLDATX real-time application files to run on my Speedgoat using this dialog:
Then, I deployed this app to a standalone executable using MATLAB Compiler. However, when I try to click the "Load Application" button in the standalone app, either nothing happens (no dialog opens), or the following error occurs when attempting to load the MLDATX file:
Dot indexing into the result of a function call requires parentheses after the function name. The supported syntax is ‘sIrealtime().internal’.
Since R2024a:
Error communicating with target ‘xx.xx.xx.xx’: Specify the real-time application name in the ‘Application’ property of the Load Button component in the instrument panel app.
Then, I tried to implement a manual logic in my app using app.tg.load() that switches between MLDATX files of the same name located in different folders. This works when launching the app from MATLAB, but not when it’s deployed. slrt, app, loadbutton, load, application, slrtappgenerator MATLAB Answers — New Questions
How to Sort Matrix Rows from Highest to Lowest
Simplied my problem so it’s easier to solve. Let’s pretend I have MatrixA that has 2 columns, and I want to sort the rows from highest to lowest depending on the value of the cell in the second column. How would I do this?
I also have a VectorB that starts at 10 and would like to add the value of each row in column 2 of the sorted MatrixA. How would I do this? Note this needs to come after MatrixA is sorted from highest to lowest.
Any suggestions matlab wizards out there? Really want to avoid using loops to make the code inefficient.
%Just creating example of the matrix I want to sort you can ignore this
MatrixA = cell(3,2);
MatrixA{1,1} = "D1";
MatrixA{2,1} = "D2";
MatrixA{3,1} = "D3";
MatrixA{1,2} = 5;
MatrixA{2,2} = 15;
MatrixA{3,2} = 10;
% Creating Vector B based on the already defined values for MatrixA which aren’t in order
VectorA = [10 10+MatrixA{1,2} 10+MatrixA{2,2} 10+MatrixA{3,2}];
% How would I sort MatrixA from highest to lowest here and the values of VectorB to be based on the sorted MatrixA?Simplied my problem so it’s easier to solve. Let’s pretend I have MatrixA that has 2 columns, and I want to sort the rows from highest to lowest depending on the value of the cell in the second column. How would I do this?
I also have a VectorB that starts at 10 and would like to add the value of each row in column 2 of the sorted MatrixA. How would I do this? Note this needs to come after MatrixA is sorted from highest to lowest.
Any suggestions matlab wizards out there? Really want to avoid using loops to make the code inefficient.
%Just creating example of the matrix I want to sort you can ignore this
MatrixA = cell(3,2);
MatrixA{1,1} = "D1";
MatrixA{2,1} = "D2";
MatrixA{3,1} = "D3";
MatrixA{1,2} = 5;
MatrixA{2,2} = 15;
MatrixA{3,2} = 10;
% Creating Vector B based on the already defined values for MatrixA which aren’t in order
VectorA = [10 10+MatrixA{1,2} 10+MatrixA{2,2} 10+MatrixA{3,2}];
% How would I sort MatrixA from highest to lowest here and the values of VectorB to be based on the sorted MatrixA? Simplied my problem so it’s easier to solve. Let’s pretend I have MatrixA that has 2 columns, and I want to sort the rows from highest to lowest depending on the value of the cell in the second column. How would I do this?
I also have a VectorB that starts at 10 and would like to add the value of each row in column 2 of the sorted MatrixA. How would I do this? Note this needs to come after MatrixA is sorted from highest to lowest.
Any suggestions matlab wizards out there? Really want to avoid using loops to make the code inefficient.
%Just creating example of the matrix I want to sort you can ignore this
MatrixA = cell(3,2);
MatrixA{1,1} = "D1";
MatrixA{2,1} = "D2";
MatrixA{3,1} = "D3";
MatrixA{1,2} = 5;
MatrixA{2,2} = 15;
MatrixA{3,2} = 10;
% Creating Vector B based on the already defined values for MatrixA which aren’t in order
VectorA = [10 10+MatrixA{1,2} 10+MatrixA{2,2} 10+MatrixA{3,2}];
% How would I sort MatrixA from highest to lowest here and the values of VectorB to be based on the sorted MatrixA? matlab, matlab code, mathematics, matrix array, matrix, matrix manipulation, matrices, array, arrays, cell array, cell arrays, vector, vectors, vectorization, cell, excel, importing excel data, matlab function, matlab coder, struct, script, speed, solve, sort, filter, fsolve MATLAB Answers — New Questions
MATLAB and Simulink crash on Ubuntu 22.04.2
Running MATLAB R2024a on Ubuntu 22.04.2 LTS, and i found MATLAB and Simulink always get "killed" when i run a model.
This is the message i get before "killed" in terminal : (OpenGL, Performance, GL_CLOSE_PATH_NV, High): GPU stall due to ReadPixels
Also when using Budget Analyzer i am not able to change the values or add new blocks. the window seems freezed. or the buttons and my keyboard seem freezed. But on closing the window it simply get closed, and mouse clicks shows response, but unable to work with the app.Running MATLAB R2024a on Ubuntu 22.04.2 LTS, and i found MATLAB and Simulink always get "killed" when i run a model.
This is the message i get before "killed" in terminal : (OpenGL, Performance, GL_CLOSE_PATH_NV, High): GPU stall due to ReadPixels
Also when using Budget Analyzer i am not able to change the values or add new blocks. the window seems freezed. or the buttons and my keyboard seem freezed. But on closing the window it simply get closed, and mouse clicks shows response, but unable to work with the app. Running MATLAB R2024a on Ubuntu 22.04.2 LTS, and i found MATLAB and Simulink always get "killed" when i run a model.
This is the message i get before "killed" in terminal : (OpenGL, Performance, GL_CLOSE_PATH_NV, High): GPU stall due to ReadPixels
Also when using Budget Analyzer i am not able to change the values or add new blocks. the window seems freezed. or the buttons and my keyboard seem freezed. But on closing the window it simply get closed, and mouse clicks shows response, but unable to work with the app. #performance, ubuntu, 22.04, simulink, budget analyzer, crash, opengl MATLAB Answers — New Questions
Calculating Power of Specific Spatial Frequencies of pictures
Hi experts,
I want to calculate the power of the spatial frequency range 20-30 cycles per picture in an picture. I am not sure how I can accomplish this using MATLAB code. FYI. Cycles per picture is a spatial frequency unit, also called cycles per image.
I downloaded following code online and made some modifications. Could you check the code for me and tell me whether I am correct?
% 1. Read the image
img = imread(‘your_image.jpg’);
img_gray = rgb2gray(img); % Convert to grayscale if the image is colored
% 2. Compute the Fourier transform of the image
img_fft = fft2(double(img_gray));
img_fft_shifted = fftshift(img_fft);
% Get the size of the image
[rows, cols] = size(img_gray);
% Compute the frequency coordinates
u = (-rows/2:(rows/2-1)) / rows;
v = (-cols/2:(cols/2-1)) / cols;
[U, V] = meshgrid(u, v);
D = sqrt(U.^2 + V.^2);
% 3. Calculate the power in the 20-30 cycles per image range
freq_low = 20 / rows;
freq_high = 30 / rows;
mask = (D >= freq_low) & (D <= freq_high);
energy = sum(sum(abs(img_fft_shifted .* mask).^2));
% Output the power
fprintf(‘Power in the range 20-30 cycles per image: %fn’, energy);Hi experts,
I want to calculate the power of the spatial frequency range 20-30 cycles per picture in an picture. I am not sure how I can accomplish this using MATLAB code. FYI. Cycles per picture is a spatial frequency unit, also called cycles per image.
I downloaded following code online and made some modifications. Could you check the code for me and tell me whether I am correct?
% 1. Read the image
img = imread(‘your_image.jpg’);
img_gray = rgb2gray(img); % Convert to grayscale if the image is colored
% 2. Compute the Fourier transform of the image
img_fft = fft2(double(img_gray));
img_fft_shifted = fftshift(img_fft);
% Get the size of the image
[rows, cols] = size(img_gray);
% Compute the frequency coordinates
u = (-rows/2:(rows/2-1)) / rows;
v = (-cols/2:(cols/2-1)) / cols;
[U, V] = meshgrid(u, v);
D = sqrt(U.^2 + V.^2);
% 3. Calculate the power in the 20-30 cycles per image range
freq_low = 20 / rows;
freq_high = 30 / rows;
mask = (D >= freq_low) & (D <= freq_high);
energy = sum(sum(abs(img_fft_shifted .* mask).^2));
% Output the power
fprintf(‘Power in the range 20-30 cycles per image: %fn’, energy); Hi experts,
I want to calculate the power of the spatial frequency range 20-30 cycles per picture in an picture. I am not sure how I can accomplish this using MATLAB code. FYI. Cycles per picture is a spatial frequency unit, also called cycles per image.
I downloaded following code online and made some modifications. Could you check the code for me and tell me whether I am correct?
% 1. Read the image
img = imread(‘your_image.jpg’);
img_gray = rgb2gray(img); % Convert to grayscale if the image is colored
% 2. Compute the Fourier transform of the image
img_fft = fft2(double(img_gray));
img_fft_shifted = fftshift(img_fft);
% Get the size of the image
[rows, cols] = size(img_gray);
% Compute the frequency coordinates
u = (-rows/2:(rows/2-1)) / rows;
v = (-cols/2:(cols/2-1)) / cols;
[U, V] = meshgrid(u, v);
D = sqrt(U.^2 + V.^2);
% 3. Calculate the power in the 20-30 cycles per image range
freq_low = 20 / rows;
freq_high = 30 / rows;
mask = (D >= freq_low) & (D <= freq_high);
energy = sum(sum(abs(img_fft_shifted .* mask).^2));
% Output the power
fprintf(‘Power in the range 20-30 cycles per image: %fn’, energy); digital image processing, fft2, fftshift MATLAB Answers — New Questions