Author: PuTI
Strange behaviour using double
I’m currently using Matlab 2020b
The doumentation for the double function states that ‘Converting a string that does not represent a single numeric value to double will produce a NaN result’. Based on this, I am using isnan(double(string(‘chars’))) to check whether a user inputted character vector represents a number or not. One particular case I wish to guard against is users entering a ‘,’ instaed of ‘.’. This works very well, except if the vector in question has a comma followed by exactly 3 numerals, in which case double tells me it is a number. For example, the vector ‘1.23’ will produce NaN, but ‘1,234’ gives the number 1234. Any other number of characters after the comma gives NaN (as far as I can tell).
Does anybody understand why this is and is there a way to get it to do what I actually want?
ThanksI’m currently using Matlab 2020b
The doumentation for the double function states that ‘Converting a string that does not represent a single numeric value to double will produce a NaN result’. Based on this, I am using isnan(double(string(‘chars’))) to check whether a user inputted character vector represents a number or not. One particular case I wish to guard against is users entering a ‘,’ instaed of ‘.’. This works very well, except if the vector in question has a comma followed by exactly 3 numerals, in which case double tells me it is a number. For example, the vector ‘1.23’ will produce NaN, but ‘1,234’ gives the number 1234. Any other number of characters after the comma gives NaN (as far as I can tell).
Does anybody understand why this is and is there a way to get it to do what I actually want?
Thanks I’m currently using Matlab 2020b
The doumentation for the double function states that ‘Converting a string that does not represent a single numeric value to double will produce a NaN result’. Based on this, I am using isnan(double(string(‘chars’))) to check whether a user inputted character vector represents a number or not. One particular case I wish to guard against is users entering a ‘,’ instaed of ‘.’. This works very well, except if the vector in question has a comma followed by exactly 3 numerals, in which case double tells me it is a number. For example, the vector ‘1.23’ will produce NaN, but ‘1,234’ gives the number 1234. Any other number of characters after the comma gives NaN (as far as I can tell).
Does anybody understand why this is and is there a way to get it to do what I actually want?
Thanks double MATLAB Answers — New Questions
Please provide me the matlab code for 8-bit integer arithmetic coding and decoding.
I am currently using 8-bit integer arithmetic encoding to compress a binary vector of approximately 7000 bits in MATLAB. However, after decoding the arithmetic encoding, the reconstructed binary vector does not match the original input. Could you please provide MATLAB code for 8-bit integer arithmetic encoding and decoding that ensures full recovery of the original data?I am currently using 8-bit integer arithmetic encoding to compress a binary vector of approximately 7000 bits in MATLAB. However, after decoding the arithmetic encoding, the reconstructed binary vector does not match the original input. Could you please provide MATLAB code for 8-bit integer arithmetic encoding and decoding that ensures full recovery of the original data? I am currently using 8-bit integer arithmetic encoding to compress a binary vector of approximately 7000 bits in MATLAB. However, after decoding the arithmetic encoding, the reconstructed binary vector does not match the original input. Could you please provide MATLAB code for 8-bit integer arithmetic encoding and decoding that ensures full recovery of the original data? 8-bit integer arithmetic coding MATLAB Answers — New Questions
Issues creating error bar for bar figure
Hi,
I’m trying to create error bars on my bar plot.
I get the error: "Input arguments must be numeric, datetime, duration, or categorical."
I’m not sure what I’m doing wrong. Even when I make err equal to two numbers it still doesn’t work.
AMean = 656631
BMean = 1130
ASTD = 237027
BSTD = 209
AHeight = 10
BHeight = 11
Names = ["A"; "B" ] ;
Averages = [AMean; BMean] ;
StandDev = [ASTD ; BSTD] ;
SampSize = [AHeight; BHeight] ;
NewTable = table(Names, Averages, StandDev, SampSize) ;
x = NewTable.Names ;
y = NewTable.Averages ;
err = StandDev ./ sqrt(SampSize) ;
bar(x, y)
errorbar(x,y,err)Hi,
I’m trying to create error bars on my bar plot.
I get the error: "Input arguments must be numeric, datetime, duration, or categorical."
I’m not sure what I’m doing wrong. Even when I make err equal to two numbers it still doesn’t work.
AMean = 656631
BMean = 1130
ASTD = 237027
BSTD = 209
AHeight = 10
BHeight = 11
Names = ["A"; "B" ] ;
Averages = [AMean; BMean] ;
StandDev = [ASTD ; BSTD] ;
SampSize = [AHeight; BHeight] ;
NewTable = table(Names, Averages, StandDev, SampSize) ;
x = NewTable.Names ;
y = NewTable.Averages ;
err = StandDev ./ sqrt(SampSize) ;
bar(x, y)
errorbar(x,y,err) Hi,
I’m trying to create error bars on my bar plot.
I get the error: "Input arguments must be numeric, datetime, duration, or categorical."
I’m not sure what I’m doing wrong. Even when I make err equal to two numbers it still doesn’t work.
AMean = 656631
BMean = 1130
ASTD = 237027
BSTD = 209
AHeight = 10
BHeight = 11
Names = ["A"; "B" ] ;
Averages = [AMean; BMean] ;
StandDev = [ASTD ; BSTD] ;
SampSize = [AHeight; BHeight] ;
NewTable = table(Names, Averages, StandDev, SampSize) ;
x = NewTable.Names ;
y = NewTable.Averages ;
err = StandDev ./ sqrt(SampSize) ;
bar(x, y)
errorbar(x,y,err) error bar, graphing MATLAB Answers — New Questions
unable to open timetables from workspace
Hello Matlab Comminity,
I have just updated my MATLAB to R2025a and I can not open the timetables from my workspace.
Other variables (numeric arrays, tables, timerange objects) open fine. With timetables, the workspace either becomes unresponsive or never shows the variable. No explicit error dialog appears.If I write the variable to command window, I can see the content but it is not what I need.
It seems like a strange error or unresponsive and i do not know how to fix this.
Is there any idea to remove this trouble?
Thank you in advance for your time.Hello Matlab Comminity,
I have just updated my MATLAB to R2025a and I can not open the timetables from my workspace.
Other variables (numeric arrays, tables, timerange objects) open fine. With timetables, the workspace either becomes unresponsive or never shows the variable. No explicit error dialog appears.If I write the variable to command window, I can see the content but it is not what I need.
It seems like a strange error or unresponsive and i do not know how to fix this.
Is there any idea to remove this trouble?
Thank you in advance for your time. Hello Matlab Comminity,
I have just updated my MATLAB to R2025a and I can not open the timetables from my workspace.
Other variables (numeric arrays, tables, timerange objects) open fine. With timetables, the workspace either becomes unresponsive or never shows the variable. No explicit error dialog appears.If I write the variable to command window, I can see the content but it is not what I need.
It seems like a strange error or unresponsive and i do not know how to fix this.
Is there any idea to remove this trouble?
Thank you in advance for your time. workspace, timetable MATLAB Answers — New Questions
startRecording() not reliable in real-time app? New file logs not being created when expected
I used this Mathworks post to implement an intermittent file logging method in my real-time app running on Speedgoat.
I created a long duration (10’s on minutes) timer with a callback. The callback performs stopRecording() and then startRecording(), which should create a new log file.
The timer looks something like this:
timer(‘ExecutionMode’, ‘fixedRate’, ‘Period’, 600, ‘TimerFcn’, @(~,~)app.createNewLogFile(app))
createNewLogFile() does the following:
stopRecording(app.tg)
short pause()
startRecording(app.tg)
Checks whether a new log file was created (it should be from stopping/restarting)
This works the majority of the time, but fails intermittently. I performed basic troubleshooting to see that it fails to log for a period of time when the callback fails. I can see that it stopped recording but did not restart within that failed callback.
Extra info:
There is no Enable Log File block in the model because its documentation page says that it can affect the usage of recording functions
I have tried giving the stop/restart calls multiple attempts within the same timer callback. It seems that if it fails the first attempt in a timer callback, it fails repeatedly within that callback
I want the timed log functionality to be in the App because I want the ability for an App user to toggle it. Meaning that in-model default timer solutions don’t work as an alternative
I would like to learn how to fish here. What can I do to truly understand why/how a startRecording() call would not work? Is there something about housing this behavior within a timer callback on the host side that makes it unreliable for sending commands to the target? It doesn’t seem like it should be since the timer is very long duration in comparison to the callback commands.
If I understand the documentation correctly, there is a target->host ACK built in to the stopRecording() and startRecording() functions? So I would expect the restart to fail the acknowledge step if it did not go through. But I don’t see a failure.
Thanks for any insight here.I used this Mathworks post to implement an intermittent file logging method in my real-time app running on Speedgoat.
I created a long duration (10’s on minutes) timer with a callback. The callback performs stopRecording() and then startRecording(), which should create a new log file.
The timer looks something like this:
timer(‘ExecutionMode’, ‘fixedRate’, ‘Period’, 600, ‘TimerFcn’, @(~,~)app.createNewLogFile(app))
createNewLogFile() does the following:
stopRecording(app.tg)
short pause()
startRecording(app.tg)
Checks whether a new log file was created (it should be from stopping/restarting)
This works the majority of the time, but fails intermittently. I performed basic troubleshooting to see that it fails to log for a period of time when the callback fails. I can see that it stopped recording but did not restart within that failed callback.
Extra info:
There is no Enable Log File block in the model because its documentation page says that it can affect the usage of recording functions
I have tried giving the stop/restart calls multiple attempts within the same timer callback. It seems that if it fails the first attempt in a timer callback, it fails repeatedly within that callback
I want the timed log functionality to be in the App because I want the ability for an App user to toggle it. Meaning that in-model default timer solutions don’t work as an alternative
I would like to learn how to fish here. What can I do to truly understand why/how a startRecording() call would not work? Is there something about housing this behavior within a timer callback on the host side that makes it unreliable for sending commands to the target? It doesn’t seem like it should be since the timer is very long duration in comparison to the callback commands.
If I understand the documentation correctly, there is a target->host ACK built in to the stopRecording() and startRecording() functions? So I would expect the restart to fail the acknowledge step if it did not go through. But I don’t see a failure.
Thanks for any insight here. I used this Mathworks post to implement an intermittent file logging method in my real-time app running on Speedgoat.
I created a long duration (10’s on minutes) timer with a callback. The callback performs stopRecording() and then startRecording(), which should create a new log file.
The timer looks something like this:
timer(‘ExecutionMode’, ‘fixedRate’, ‘Period’, 600, ‘TimerFcn’, @(~,~)app.createNewLogFile(app))
createNewLogFile() does the following:
stopRecording(app.tg)
short pause()
startRecording(app.tg)
Checks whether a new log file was created (it should be from stopping/restarting)
This works the majority of the time, but fails intermittently. I performed basic troubleshooting to see that it fails to log for a period of time when the callback fails. I can see that it stopped recording but did not restart within that failed callback.
Extra info:
There is no Enable Log File block in the model because its documentation page says that it can affect the usage of recording functions
I have tried giving the stop/restart calls multiple attempts within the same timer callback. It seems that if it fails the first attempt in a timer callback, it fails repeatedly within that callback
I want the timed log functionality to be in the App because I want the ability for an App user to toggle it. Meaning that in-model default timer solutions don’t work as an alternative
I would like to learn how to fish here. What can I do to truly understand why/how a startRecording() call would not work? Is there something about housing this behavior within a timer callback on the host side that makes it unreliable for sending commands to the target? It doesn’t seem like it should be since the timer is very long duration in comparison to the callback commands.
If I understand the documentation correctly, there is a target->host ACK built in to the stopRecording() and startRecording() functions? So I would expect the restart to fail the acknowledge step if it did not go through. But I don’t see a failure.
Thanks for any insight here. app designer, timer, real-time MATLAB Answers — New Questions
Compare two row and select appropriate data
I have two columns. Let’s call them column a and column b.
I want to do a check where:
if row 1 of column a > row 1 of column b, use row 1 of column a. Else, use row 1 of column b.
I have tried
if Column a > Column b
Column c = column b
else
Column c = column a
end
However, when I check the data, I find out some of the function isn’t working and it just pulls all the data from column a into column c.
Basically column b is the "cap." And no number in column c should be greater than that. If any numbers in column a is greater than column b, column b should be used.I have two columns. Let’s call them column a and column b.
I want to do a check where:
if row 1 of column a > row 1 of column b, use row 1 of column a. Else, use row 1 of column b.
I have tried
if Column a > Column b
Column c = column b
else
Column c = column a
end
However, when I check the data, I find out some of the function isn’t working and it just pulls all the data from column a into column c.
Basically column b is the "cap." And no number in column c should be greater than that. If any numbers in column a is greater than column b, column b should be used. I have two columns. Let’s call them column a and column b.
I want to do a check where:
if row 1 of column a > row 1 of column b, use row 1 of column a. Else, use row 1 of column b.
I have tried
if Column a > Column b
Column c = column b
else
Column c = column a
end
However, when I check the data, I find out some of the function isn’t working and it just pulls all the data from column a into column c.
Basically column b is the "cap." And no number in column c should be greater than that. If any numbers in column a is greater than column b, column b should be used. comparison, matlab MATLAB Answers — New Questions
How can I solve a problem that is related to Fuzzy Logic Designer
Hi… I have designed a fuzzy controller that I want to tune. The dataset I currently have contains output from another software, recorded over time. Consider that I read two inputs and generate an output, and the resulting table provides data over a 60-second period. How can I import this dataset into MATLAB and use it for tuning my fuzzy controller?
Fuzzy Controller designed in Fuzzy Logic Designer app:
Data sample:Hi… I have designed a fuzzy controller that I want to tune. The dataset I currently have contains output from another software, recorded over time. Consider that I read two inputs and generate an output, and the resulting table provides data over a 60-second period. How can I import this dataset into MATLAB and use it for tuning my fuzzy controller?
Fuzzy Controller designed in Fuzzy Logic Designer app:
Data sample: Hi… I have designed a fuzzy controller that I want to tune. The dataset I currently have contains output from another software, recorded over time. Consider that I read two inputs and generate an output, and the resulting table provides data over a 60-second period. How can I import this dataset into MATLAB and use it for tuning my fuzzy controller?
Fuzzy Controller designed in Fuzzy Logic Designer app:
Data sample: fuzzy logic controller, fuzzy logic designer MATLAB Answers — New Questions
How to add two columns based on conditions
I was going to try to write a very basic loop (to familiarize myself with writing loops), otherwise not using a loop would probably cost less.
I have a large matrix, but for simplicity, I am trying to add 2 columns together and create the sum in another column in the same matrix.
I want to have two conditions to be met in order for the addition to take place, if conditions are not met, then do not combine values, but still generate the first value.
So I want to add column 3 and 4, if column 1 x<1.5 and if column 2 x==0, then insert into column 5. If the critieria is not met, then copy value from column 3 into 5.
1 0 1 4 5
2 0 1 5 1
1 1.5 2 1 2
if intrun(:,1)<1.50) & (intrun(:,2)==0;
intrun(:,5)= intrun(:,3)+intrun(:,4);
end
Thank YouI was going to try to write a very basic loop (to familiarize myself with writing loops), otherwise not using a loop would probably cost less.
I have a large matrix, but for simplicity, I am trying to add 2 columns together and create the sum in another column in the same matrix.
I want to have two conditions to be met in order for the addition to take place, if conditions are not met, then do not combine values, but still generate the first value.
So I want to add column 3 and 4, if column 1 x<1.5 and if column 2 x==0, then insert into column 5. If the critieria is not met, then copy value from column 3 into 5.
1 0 1 4 5
2 0 1 5 1
1 1.5 2 1 2
if intrun(:,1)<1.50) & (intrun(:,2)==0;
intrun(:,5)= intrun(:,3)+intrun(:,4);
end
Thank You I was going to try to write a very basic loop (to familiarize myself with writing loops), otherwise not using a loop would probably cost less.
I have a large matrix, but for simplicity, I am trying to add 2 columns together and create the sum in another column in the same matrix.
I want to have two conditions to be met in order for the addition to take place, if conditions are not met, then do not combine values, but still generate the first value.
So I want to add column 3 and 4, if column 1 x<1.5 and if column 2 x==0, then insert into column 5. If the critieria is not met, then copy value from column 3 into 5.
1 0 1 4 5
2 0 1 5 1
1 1.5 2 1 2
if intrun(:,1)<1.50) & (intrun(:,2)==0;
intrun(:,5)= intrun(:,3)+intrun(:,4);
end
Thank You for loop MATLAB Answers — New Questions
Flexible work update
Amy Coleman, Executive Vice President and Chief People Officer, shared the below communication with Microsoft employees this morning.
How we work has forever changed. I remember starting at Microsoft in the late ‘90s, always in the office, no laptops, and primarily working with the people right down the hall. As technology evolved and our business expanded, we became more open, more global, and able to scale in ways we couldn’t have imagined. Then the pandemic reshaped everything. It pushed us to think differently about work, to connect like never before (thank you Teams!), reminded us of how much we value being together, and gave us focus and autonomy in the traditional workday. We’re not going back, and we shouldn’t. Instead, we should take the best of what we’ve learned and move forward.
In the AI era, we are moving faster than ever, building world-class technology that changes how people live and work, and how organizations everywhere operate. If you reflect on our history, the most meaningful breakthroughs happen when we build on each other’s ideas together, in real time.
We’ve looked at how our teams work best, and the data is clear: when people work together in person more often, they thrive — they are more energized, empowered, and they deliver stronger results. As we build the AI products that will define this era, we need the kind of energy and momentum that comes from smart people working side by side, solving challenging problems together.
With that in mind, we’re updating our flexible work expectations to three days a week in the office.
We’ll roll this out in three phases: 1) starting in Puget Sound at the end of February; 2) expanding to other US locations; 3) then launching outside the US.
Our goal with this change is to provide more clarity and consistency in how we come together, while maintaining the flexibility we know you value. We want you to continue to shape your schedule in ways that work best for you, making in-person time intentional and impactful. Importantly, this update is not about reducing headcount. It’s about working together in a way that enables us to meet our customers’ needs.
For some of you, this is not a change. For others this may be a bigger adjustment, which is exactly why we’re providing time to plan thoughtfully. As part of these updates, we’re also enhancing our workplace safety and security measures so we can continue to provide a workplace where every employee can do their best work.
What you need to know:
Puget Sound-area employees: If you live within 50 miles of a Microsoft office, you’ll be expected to work onsite three days a week by the end of February 2026. You’ll receive a personalized email today with more details. Please connect with your manager and team to understand your organization’s plans. If needed, you can request an exception by Friday, September 19.
Managers: You’ll find actions to take, and the resources to support both you and your team on the Managers@Microsoft SharePoint.
All employees: You’ll hear from your EVP or organizational leadership today with specific guidance. Each business will do what is best for their team, which means some groups will deviate from our company-wide expectations. If you are outside of the Puget Sound area, you do not need to take any action at this time unless your EVP communicates otherwise.
Timelines and details for additional US office locations will be announced soon. For employees outside the United States, we will begin planning in 2026. More information is available on the Flexible Work at Microsoft SharePoint.
As always, we’ll keep learning together to ensure Microsoft is the best place for you to grow and have a great career. Let’s keep moving forward together.
Thank you,
Amy
The post Flexible work update appeared first on The Official Microsoft Blog.
Amy Coleman, Executive Vice President and Chief People Officer, shared the below communication with Microsoft employees this morning. How we work has forever changed. I remember starting at Microsoft in the late ‘90s, always in the office, no laptops, and primarily working with the people right down the hall. As technology evolved and our business expanded, we became…
The post Flexible work update appeared first on The Official Microsoft Blog.Read More
Identify exact jittered point from swarmchart plot
I created a horizontal swarmchart in app designer. The input data have numeric values and grouping tags (intGroups) associated with each point. Each point’s color is associated with its group. I also defined a ButtonDownFcn to get the point that the user clicks on (using code from a previous Matlab Answer).
The issue is that when I click a point, swarmchart’s XData and YData give the undithered coordinates (i.e., the y-values are all the same). So if I click a point that is far from center (due to a lot of points having that same value), the code below may or may not identify that point I clicked, so I may not get the correct group.
Is there a way to ensure that I get the exact point I clicked (or its index in the vector), not others that are in the same vicinity?
for zz = 1:length(intVarsUnique)
hPlot = swarmchart(axPlot, xData(:, zz), intVars(:, zz), [], categorical(strGroupColors), ‘filled’, ‘o’, …
‘YJitter’,’density’, …
‘HitTest’, ‘on’, ‘ButtonDownFcn’, @(src, eventData) fcnPlot_ButtonDown(app, src, eventData));
if ~ishold(axPlot)
hold(axPlot, ‘on’);
end
end % zz
hold(axPlot, ‘off’);
function fcnPlot_ButtonDown(app, hPlot, eventData)
% Based on code from Yair Altman in https://www.mathworks.com/matlabcentral/answers/1903190-get-data-point-that-was-clicked-on-in-graph
% Get the click coordinates from the click event data
x = eventData.IntersectionPoint(1);
y = eventData.IntersectionPoint(2);
line_xs = hPlot.XData;
line_ys = hPlot.YData;
dist2 = (x-line_xs).^2 + (y-line_ys).^2;
[~,min_idx] = min(dist2);
closest_x = line_xs(min_idx);
closest_y = line_ys(min_idx);
msgbox(sprintf(‘Clicked on: (%g,%g)nClosest pt: (%g,%g)’, x, y, closest_x, closest_y));
% Code to locate point in vector and ID group…
endI created a horizontal swarmchart in app designer. The input data have numeric values and grouping tags (intGroups) associated with each point. Each point’s color is associated with its group. I also defined a ButtonDownFcn to get the point that the user clicks on (using code from a previous Matlab Answer).
The issue is that when I click a point, swarmchart’s XData and YData give the undithered coordinates (i.e., the y-values are all the same). So if I click a point that is far from center (due to a lot of points having that same value), the code below may or may not identify that point I clicked, so I may not get the correct group.
Is there a way to ensure that I get the exact point I clicked (or its index in the vector), not others that are in the same vicinity?
for zz = 1:length(intVarsUnique)
hPlot = swarmchart(axPlot, xData(:, zz), intVars(:, zz), [], categorical(strGroupColors), ‘filled’, ‘o’, …
‘YJitter’,’density’, …
‘HitTest’, ‘on’, ‘ButtonDownFcn’, @(src, eventData) fcnPlot_ButtonDown(app, src, eventData));
if ~ishold(axPlot)
hold(axPlot, ‘on’);
end
end % zz
hold(axPlot, ‘off’);
function fcnPlot_ButtonDown(app, hPlot, eventData)
% Based on code from Yair Altman in https://www.mathworks.com/matlabcentral/answers/1903190-get-data-point-that-was-clicked-on-in-graph
% Get the click coordinates from the click event data
x = eventData.IntersectionPoint(1);
y = eventData.IntersectionPoint(2);
line_xs = hPlot.XData;
line_ys = hPlot.YData;
dist2 = (x-line_xs).^2 + (y-line_ys).^2;
[~,min_idx] = min(dist2);
closest_x = line_xs(min_idx);
closest_y = line_ys(min_idx);
msgbox(sprintf(‘Clicked on: (%g,%g)nClosest pt: (%g,%g)’, x, y, closest_x, closest_y));
% Code to locate point in vector and ID group…
end I created a horizontal swarmchart in app designer. The input data have numeric values and grouping tags (intGroups) associated with each point. Each point’s color is associated with its group. I also defined a ButtonDownFcn to get the point that the user clicks on (using code from a previous Matlab Answer).
The issue is that when I click a point, swarmchart’s XData and YData give the undithered coordinates (i.e., the y-values are all the same). So if I click a point that is far from center (due to a lot of points having that same value), the code below may or may not identify that point I clicked, so I may not get the correct group.
Is there a way to ensure that I get the exact point I clicked (or its index in the vector), not others that are in the same vicinity?
for zz = 1:length(intVarsUnique)
hPlot = swarmchart(axPlot, xData(:, zz), intVars(:, zz), [], categorical(strGroupColors), ‘filled’, ‘o’, …
‘YJitter’,’density’, …
‘HitTest’, ‘on’, ‘ButtonDownFcn’, @(src, eventData) fcnPlot_ButtonDown(app, src, eventData));
if ~ishold(axPlot)
hold(axPlot, ‘on’);
end
end % zz
hold(axPlot, ‘off’);
function fcnPlot_ButtonDown(app, hPlot, eventData)
% Based on code from Yair Altman in https://www.mathworks.com/matlabcentral/answers/1903190-get-data-point-that-was-clicked-on-in-graph
% Get the click coordinates from the click event data
x = eventData.IntersectionPoint(1);
y = eventData.IntersectionPoint(2);
line_xs = hPlot.XData;
line_ys = hPlot.YData;
dist2 = (x-line_xs).^2 + (y-line_ys).^2;
[~,min_idx] = min(dist2);
closest_x = line_xs(min_idx);
closest_y = line_ys(min_idx);
msgbox(sprintf(‘Clicked on: (%g,%g)nClosest pt: (%g,%g)’, x, y, closest_x, closest_y));
% Code to locate point in vector and ID group…
end matlab, swarmchart, appdesigner, undocumented MATLAB Answers — New Questions
Default button of “questdlg” not working in 2025a
answer = questdlg(quest,dlgtitle,btn1,btn2,btn3,defbtn)
When the dialogue box is opened, the default button is selected, but pressing ENTER won’t click the button, and pressing ESC won’t close the dialogue box.answer = questdlg(quest,dlgtitle,btn1,btn2,btn3,defbtn)
When the dialogue box is opened, the default button is selected, but pressing ENTER won’t click the button, and pressing ESC won’t close the dialogue box. answer = questdlg(quest,dlgtitle,btn1,btn2,btn3,defbtn)
When the dialogue box is opened, the default button is selected, but pressing ENTER won’t click the button, and pressing ESC won’t close the dialogue box. matlab gui, nevermind – works now MATLAB Answers — New Questions
start app by doubleclicking mat-file with custom extension
An application which was greated using GUIDE can save *.mat files with a cusom extension, like *.MyExtension. What I want is, that I doubleclick in the windows explorer such a file, which will:
1. open my application (probably some settings in windows)
2. pass the file path to the application, so that the data can be loaded. Can someone help me on this?An application which was greated using GUIDE can save *.mat files with a cusom extension, like *.MyExtension. What I want is, that I doubleclick in the windows explorer such a file, which will:
1. open my application (probably some settings in windows)
2. pass the file path to the application, so that the data can be loaded. Can someone help me on this? An application which was greated using GUIDE can save *.mat files with a cusom extension, like *.MyExtension. What I want is, that I doubleclick in the windows explorer such a file, which will:
1. open my application (probably some settings in windows)
2. pass the file path to the application, so that the data can be loaded. Can someone help me on this? load file in application MATLAB Answers — New Questions
Performing 2D convolution
Hello,
I am new to image processing and had a conceptual question. I am currently trying to perform a 2D convolution of an image and a kernel (filter) in simulink using the 2D convolution block. I have code that transposes the image, then flips it, then performs the 2D convolution with the kernel. However from my (very limited) understanding convolution already flips the filter that I want to apply. I was told that the output of me transposing and flipping the image, then convolving with the kernel looks correct, however from my understanding I would be transposing and flipping the image once then convolving, which involves another flip, so therefore not actually convolving? I have read that this would just produce instead a correlation?
Hoping someone who knows more may be able to help give me a better understanding.
Thank you!Hello,
I am new to image processing and had a conceptual question. I am currently trying to perform a 2D convolution of an image and a kernel (filter) in simulink using the 2D convolution block. I have code that transposes the image, then flips it, then performs the 2D convolution with the kernel. However from my (very limited) understanding convolution already flips the filter that I want to apply. I was told that the output of me transposing and flipping the image, then convolving with the kernel looks correct, however from my understanding I would be transposing and flipping the image once then convolving, which involves another flip, so therefore not actually convolving? I have read that this would just produce instead a correlation?
Hoping someone who knows more may be able to help give me a better understanding.
Thank you! Hello,
I am new to image processing and had a conceptual question. I am currently trying to perform a 2D convolution of an image and a kernel (filter) in simulink using the 2D convolution block. I have code that transposes the image, then flips it, then performs the 2D convolution with the kernel. However from my (very limited) understanding convolution already flips the filter that I want to apply. I was told that the output of me transposing and flipping the image, then convolving with the kernel looks correct, however from my understanding I would be transposing and flipping the image once then convolving, which involves another flip, so therefore not actually convolving? I have read that this would just produce instead a correlation?
Hoping someone who knows more may be able to help give me a better understanding.
Thank you! convolution, simulink, image processing MATLAB Answers — New Questions
Problem on startup. MacMini M4, Sequoia 15.6.1
On starup I get this meggage:
Ubable yo communicate with required MathWorks services (error 201)
Any ideas?On starup I get this meggage:
Ubable yo communicate with required MathWorks services (error 201)
Any ideas? On starup I get this meggage:
Ubable yo communicate with required MathWorks services (error 201)
Any ideas? jon’s q MATLAB Answers — New Questions
Why am I not getting printed all zones and info from one column in my table?
Here are the steps that lead to the results:
1) You start by running app2_tester that leads to app3_tester ( for making the problem simpler, I have just made it possible choosing just one combination of salts, NaCl KCl and ZnBr2: so that I don’t need to attach many function files, though there are listed up many salts in the listbox of app3_tester.
2) Each time you have pressed the choices for every zone, you press the button “done with the zone”, for instance when you in start have chosen that there are two zones, you first begin to selecting information for zone1 then do the same for zone 2
3) When you have finished pressing info about both zones, you press “ computed water activity and osmotic pressure” in app2_tester
I have problems in app2_tester and app3_tester. The other apps and some functions that are needed to run the apps are correct. I get error in app3_tester. So what I am wondering is:
Why am I not getting the zone nr 2 writtten in my osmotic table data that is printed out when I press on the button “display results from all zones”, and neither the names of the different combinations of salts in the column called combination_of_salts in my table?
The error I get says:
Error using table (line 231)
All input variables must have the same number of rows.
Error in app3_tester/StartanalysisButtonPushed (line 259)
app.Callingapp.Osmotisk_data(app.zone_now,:) = table(app.zone_now, app.combinations_of_salts, app.vekt_prosent_best_salt_1,app.vekt_prosent_best_salt_2, app.samlet_vannaktivitet,P,effect);Here are the steps that lead to the results:
1) You start by running app2_tester that leads to app3_tester ( for making the problem simpler, I have just made it possible choosing just one combination of salts, NaCl KCl and ZnBr2: so that I don’t need to attach many function files, though there are listed up many salts in the listbox of app3_tester.
2) Each time you have pressed the choices for every zone, you press the button “done with the zone”, for instance when you in start have chosen that there are two zones, you first begin to selecting information for zone1 then do the same for zone 2
3) When you have finished pressing info about both zones, you press “ computed water activity and osmotic pressure” in app2_tester
I have problems in app2_tester and app3_tester. The other apps and some functions that are needed to run the apps are correct. I get error in app3_tester. So what I am wondering is:
Why am I not getting the zone nr 2 writtten in my osmotic table data that is printed out when I press on the button “display results from all zones”, and neither the names of the different combinations of salts in the column called combination_of_salts in my table?
The error I get says:
Error using table (line 231)
All input variables must have the same number of rows.
Error in app3_tester/StartanalysisButtonPushed (line 259)
app.Callingapp.Osmotisk_data(app.zone_now,:) = table(app.zone_now, app.combinations_of_salts, app.vekt_prosent_best_salt_1,app.vekt_prosent_best_salt_2, app.samlet_vannaktivitet,P,effect); Here are the steps that lead to the results:
1) You start by running app2_tester that leads to app3_tester ( for making the problem simpler, I have just made it possible choosing just one combination of salts, NaCl KCl and ZnBr2: so that I don’t need to attach many function files, though there are listed up many salts in the listbox of app3_tester.
2) Each time you have pressed the choices for every zone, you press the button “done with the zone”, for instance when you in start have chosen that there are two zones, you first begin to selecting information for zone1 then do the same for zone 2
3) When you have finished pressing info about both zones, you press “ computed water activity and osmotic pressure” in app2_tester
I have problems in app2_tester and app3_tester. The other apps and some functions that are needed to run the apps are correct. I get error in app3_tester. So what I am wondering is:
Why am I not getting the zone nr 2 writtten in my osmotic table data that is printed out when I press on the button “display results from all zones”, and neither the names of the different combinations of salts in the column called combination_of_salts in my table?
The error I get says:
Error using table (line 231)
All input variables must have the same number of rows.
Error in app3_tester/StartanalysisButtonPushed (line 259)
app.Callingapp.Osmotisk_data(app.zone_now,:) = table(app.zone_now, app.combinations_of_salts, app.vekt_prosent_best_salt_1,app.vekt_prosent_best_salt_2, app.samlet_vannaktivitet,P,effect); appdesigner, table MATLAB Answers — New Questions
What is the fastest way to swap large blocks of data between RAM and disk storage?
Hi all. I need to work with 4 large matrix variables repeatedly in sequence. But only one of them can fit in RAM at a time. (70 GB each, 128 GB of RAM). The operations are time-sensitive, so I need to be able to load one block of data, do some computations, release the memory, load the next block…and so on, as fast as possible. I have been looking at data store & tall arrays — I could concatenate the 4 into one tall array — but that seems intended for operations that have to span more rows than memory can hold, like taking a max across all of them. Here I just need access to one contiguous block that -will- all fit in memory, but to cycle through multiple of them. What is the preferred approach? I am using the parallel processing toolbox, but am not sure how to apply parallelization to this issue in a way that doesn’t just add more overhead. Currently I save data into uncompressed v7.3 .mat files, but I can convert to whatever helps. Thanks in advance for your insights!Hi all. I need to work with 4 large matrix variables repeatedly in sequence. But only one of them can fit in RAM at a time. (70 GB each, 128 GB of RAM). The operations are time-sensitive, so I need to be able to load one block of data, do some computations, release the memory, load the next block…and so on, as fast as possible. I have been looking at data store & tall arrays — I could concatenate the 4 into one tall array — but that seems intended for operations that have to span more rows than memory can hold, like taking a max across all of them. Here I just need access to one contiguous block that -will- all fit in memory, but to cycle through multiple of them. What is the preferred approach? I am using the parallel processing toolbox, but am not sure how to apply parallelization to this issue in a way that doesn’t just add more overhead. Currently I save data into uncompressed v7.3 .mat files, but I can convert to whatever helps. Thanks in advance for your insights! Hi all. I need to work with 4 large matrix variables repeatedly in sequence. But only one of them can fit in RAM at a time. (70 GB each, 128 GB of RAM). The operations are time-sensitive, so I need to be able to load one block of data, do some computations, release the memory, load the next block…and so on, as fast as possible. I have been looking at data store & tall arrays — I could concatenate the 4 into one tall array — but that seems intended for operations that have to span more rows than memory can hold, like taking a max across all of them. Here I just need access to one contiguous block that -will- all fit in memory, but to cycle through multiple of them. What is the preferred approach? I am using the parallel processing toolbox, but am not sure how to apply parallelization to this issue in a way that doesn’t just add more overhead. Currently I save data into uncompressed v7.3 .mat files, but I can convert to whatever helps. Thanks in advance for your insights! memory management, tall arrays MATLAB Answers — New Questions
Issues with the quality difference between plots created in live script and normal script or command window.
Hey there, recently I’ve updated from 2024b to 2025a and immediately the thing that grabbed my attention was the fact that plots created in live editor and command window are vastly different in resolution and smoothness. I’ve tried searching for people with similar experience in Matlab answers but couldn’t find anything related. Some had issues with the gpu or renderer but my problem is only happening in live editor.
Here’s a comparison between a plot created in two environments:
clear; close; clc
t = linspace(0, 2*pi, 1000);
f = 4;
y = 0.8*sin(2*pi*f*t);
figure
plot(t, y)
axis tight
Lower res from live editor:
Higher res from work space:
I’ve also attached the plots incase uploding them corrupts the quality.
Now the interesting thing is that when I open up the figure window of the same plot that I had created in live editor then suddenly the quality is high again. I tried my luck with chat gpt and grok but they were pulling their results from the same forums that I had already visited so nothing useful was found that way.Hey there, recently I’ve updated from 2024b to 2025a and immediately the thing that grabbed my attention was the fact that plots created in live editor and command window are vastly different in resolution and smoothness. I’ve tried searching for people with similar experience in Matlab answers but couldn’t find anything related. Some had issues with the gpu or renderer but my problem is only happening in live editor.
Here’s a comparison between a plot created in two environments:
clear; close; clc
t = linspace(0, 2*pi, 1000);
f = 4;
y = 0.8*sin(2*pi*f*t);
figure
plot(t, y)
axis tight
Lower res from live editor:
Higher res from work space:
I’ve also attached the plots incase uploding them corrupts the quality.
Now the interesting thing is that when I open up the figure window of the same plot that I had created in live editor then suddenly the quality is high again. I tried my luck with chat gpt and grok but they were pulling their results from the same forums that I had already visited so nothing useful was found that way. Hey there, recently I’ve updated from 2024b to 2025a and immediately the thing that grabbed my attention was the fact that plots created in live editor and command window are vastly different in resolution and smoothness. I’ve tried searching for people with similar experience in Matlab answers but couldn’t find anything related. Some had issues with the gpu or renderer but my problem is only happening in live editor.
Here’s a comparison between a plot created in two environments:
clear; close; clc
t = linspace(0, 2*pi, 1000);
f = 4;
y = 0.8*sin(2*pi*f*t);
figure
plot(t, y)
axis tight
Lower res from live editor:
Higher res from work space:
I’ve also attached the plots incase uploding them corrupts the quality.
Now the interesting thing is that when I open up the figure window of the same plot that I had created in live editor then suddenly the quality is high again. I tried my luck with chat gpt and grok but they were pulling their results from the same forums that I had already visited so nothing useful was found that way. low resolution plot, live editor MATLAB Answers — New Questions
How to force Embedded coder to use a specific struct name (instead of struct_xxxxxx) for system object parameters?
I have a custom System object that uses a configuration struct returned by a helper function:
classdef Demo_setpoint_adjuster < matlab.System
properties
config = Demo.getconfig;
end
methods
function obj = Demo_setpoint_adjuster()
% Optionally initialize config/state here if needed
end
end
methods(Access = protected)
function [adjusted_setpoint] = stepImpl(obj, setpoint)
% Default passthrough implementation
% Assign outputs
adjusted_setpoint = setpoint * obj.config.gain;
% TODO implement
end
function num = getNumInputsImpl(~), num = 1; end
function varargout = getNumOutputsImpl(~), varargout = {1, []}; end
function varargout = getOutputSizeImpl(~), varargout = {1}; end
function varargout = getOutputDataTypeImpl(~), varargout = {‘double’}; end
function varargout = isOutputComplexImpl(~), varargout = {false}; end
function varargout = isOutputFixedSizeImpl(~), varargout = {true}; end
end
end
My getconfig function looks like this:
function cfg = getconfig(varargin)
cfg = Simulink.Bus.createMATLABStruct(‘DEMO_config_def’);
cfg.gain = 10;
cfg.offset = 1e-13;
coder.cstructname(cfg, ‘my_struct’);
end % end of main function getconfig
When I generate code with Embedded coder, the header file defines the parameter type as something like:
typedef struct {
real_T gain;
real_T offset;
} struct_6h72eH5WFuEIyQr5YrdGuB;
Instead of my desired:
typedef struct {
real_T gain;
real_T offset;
} my_struct;
Even though I use coder.cstructname, Simulink still generates the anonymous struct_xxxxxx
Question:
When using a System object parameter inside a simulink model, how can i ensure embedded coder generates a struct with a specific typedef name (e.g., my_struct)? Is the recommended approach to use Simulink.Bus/Simulink.Parameter, or can coder.cstructname be applied directly in this workflow?I have a custom System object that uses a configuration struct returned by a helper function:
classdef Demo_setpoint_adjuster < matlab.System
properties
config = Demo.getconfig;
end
methods
function obj = Demo_setpoint_adjuster()
% Optionally initialize config/state here if needed
end
end
methods(Access = protected)
function [adjusted_setpoint] = stepImpl(obj, setpoint)
% Default passthrough implementation
% Assign outputs
adjusted_setpoint = setpoint * obj.config.gain;
% TODO implement
end
function num = getNumInputsImpl(~), num = 1; end
function varargout = getNumOutputsImpl(~), varargout = {1, []}; end
function varargout = getOutputSizeImpl(~), varargout = {1}; end
function varargout = getOutputDataTypeImpl(~), varargout = {‘double’}; end
function varargout = isOutputComplexImpl(~), varargout = {false}; end
function varargout = isOutputFixedSizeImpl(~), varargout = {true}; end
end
end
My getconfig function looks like this:
function cfg = getconfig(varargin)
cfg = Simulink.Bus.createMATLABStruct(‘DEMO_config_def’);
cfg.gain = 10;
cfg.offset = 1e-13;
coder.cstructname(cfg, ‘my_struct’);
end % end of main function getconfig
When I generate code with Embedded coder, the header file defines the parameter type as something like:
typedef struct {
real_T gain;
real_T offset;
} struct_6h72eH5WFuEIyQr5YrdGuB;
Instead of my desired:
typedef struct {
real_T gain;
real_T offset;
} my_struct;
Even though I use coder.cstructname, Simulink still generates the anonymous struct_xxxxxx
Question:
When using a System object parameter inside a simulink model, how can i ensure embedded coder generates a struct with a specific typedef name (e.g., my_struct)? Is the recommended approach to use Simulink.Bus/Simulink.Parameter, or can coder.cstructname be applied directly in this workflow? I have a custom System object that uses a configuration struct returned by a helper function:
classdef Demo_setpoint_adjuster < matlab.System
properties
config = Demo.getconfig;
end
methods
function obj = Demo_setpoint_adjuster()
% Optionally initialize config/state here if needed
end
end
methods(Access = protected)
function [adjusted_setpoint] = stepImpl(obj, setpoint)
% Default passthrough implementation
% Assign outputs
adjusted_setpoint = setpoint * obj.config.gain;
% TODO implement
end
function num = getNumInputsImpl(~), num = 1; end
function varargout = getNumOutputsImpl(~), varargout = {1, []}; end
function varargout = getOutputSizeImpl(~), varargout = {1}; end
function varargout = getOutputDataTypeImpl(~), varargout = {‘double’}; end
function varargout = isOutputComplexImpl(~), varargout = {false}; end
function varargout = isOutputFixedSizeImpl(~), varargout = {true}; end
end
end
My getconfig function looks like this:
function cfg = getconfig(varargin)
cfg = Simulink.Bus.createMATLABStruct(‘DEMO_config_def’);
cfg.gain = 10;
cfg.offset = 1e-13;
coder.cstructname(cfg, ‘my_struct’);
end % end of main function getconfig
When I generate code with Embedded coder, the header file defines the parameter type as something like:
typedef struct {
real_T gain;
real_T offset;
} struct_6h72eH5WFuEIyQr5YrdGuB;
Instead of my desired:
typedef struct {
real_T gain;
real_T offset;
} my_struct;
Even though I use coder.cstructname, Simulink still generates the anonymous struct_xxxxxx
Question:
When using a System object parameter inside a simulink model, how can i ensure embedded coder generates a struct with a specific typedef name (e.g., my_struct)? Is the recommended approach to use Simulink.Bus/Simulink.Parameter, or can coder.cstructname be applied directly in this workflow? embedded coder MATLAB Answers — New Questions
How do I implement a script using system objects?
Hello, I am new to Simulink so please go easy on me. I am trying to implement this particular example using system objects from the related toolboxes.
https://www.mathworks.com/help/phased/ug/integrated-sensing-and-communication-2-communication-centric-approach-using-mimo-ofdm.html
I have tried using different transmitters available but it does not seem to work. Any idea to create the Tx/Rx arras and set their locations? Thanks.Hello, I am new to Simulink so please go easy on me. I am trying to implement this particular example using system objects from the related toolboxes.
https://www.mathworks.com/help/phased/ug/integrated-sensing-and-communication-2-communication-centric-approach-using-mimo-ofdm.html
I have tried using different transmitters available but it does not seem to work. Any idea to create the Tx/Rx arras and set their locations? Thanks. Hello, I am new to Simulink so please go easy on me. I am trying to implement this particular example using system objects from the related toolboxes.
https://www.mathworks.com/help/phased/ug/integrated-sensing-and-communication-2-communication-centric-approach-using-mimo-ofdm.html
I have tried using different transmitters available but it does not seem to work. Any idea to create the Tx/Rx arras and set their locations? Thanks. simulink, phased array MATLAB Answers — New Questions
How to correctly find the solution of a system of equations containing trigonometric functions
theta=70;L=1500;h=200;D=1;
eq=[l1+l2==L;
(cosd(theta)*cosd(x1)-sind(theta)*sind(x1))/x==cosd(x1)/l2;
(cosd(theta)*cosd(x1)+sind(theta)*sind(x1))/x==cosd(x1)/l1;
tand(x1)==D/(2*f);tand(x1)==x/y;cosd(theta)==h/(y+f)];
vars=[x1,l1,l2,f,x,y];
[x1,l1,l2,f,x,y]=solve(eq,vars)
The code is as above,the solution show
l1 =
7590603.4479823424160756070250191
l2 =
-7587603.8886555868349951502850662,I think the solution is wrong,but I don’t know what is wrong,Can anyone fix this?theta=70;L=1500;h=200;D=1;
eq=[l1+l2==L;
(cosd(theta)*cosd(x1)-sind(theta)*sind(x1))/x==cosd(x1)/l2;
(cosd(theta)*cosd(x1)+sind(theta)*sind(x1))/x==cosd(x1)/l1;
tand(x1)==D/(2*f);tand(x1)==x/y;cosd(theta)==h/(y+f)];
vars=[x1,l1,l2,f,x,y];
[x1,l1,l2,f,x,y]=solve(eq,vars)
The code is as above,the solution show
l1 =
7590603.4479823424160756070250191
l2 =
-7587603.8886555868349951502850662,I think the solution is wrong,but I don’t know what is wrong,Can anyone fix this? theta=70;L=1500;h=200;D=1;
eq=[l1+l2==L;
(cosd(theta)*cosd(x1)-sind(theta)*sind(x1))/x==cosd(x1)/l2;
(cosd(theta)*cosd(x1)+sind(theta)*sind(x1))/x==cosd(x1)/l1;
tand(x1)==D/(2*f);tand(x1)==x/y;cosd(theta)==h/(y+f)];
vars=[x1,l1,l2,f,x,y];
[x1,l1,l2,f,x,y]=solve(eq,vars)
The code is as above,the solution show
l1 =
7590603.4479823424160756070250191
l2 =
-7587603.8886555868349951502850662,I think the solution is wrong,but I don’t know what is wrong,Can anyone fix this? trigonometric functions;, equations MATLAB Answers — New Questions