Tag Archives: matlab
Rough Terrain in Simscape Multibody
I am trying to simulate the navigation of a vehicle over an irregular terrain in Simscape Multibody.
I would like to dynamically modify the terrain height and slope during the simulation.
Is it possible to model a terrain that translates and rotates according to a time-varying input signal, without the terrain applying accelerations or non-physical forces to the bodies in contact with it?I am trying to simulate the navigation of a vehicle over an irregular terrain in Simscape Multibody.
I would like to dynamically modify the terrain height and slope during the simulation.
Is it possible to model a terrain that translates and rotates according to a time-varying input signal, without the terrain applying accelerations or non-physical forces to the bodies in contact with it? I am trying to simulate the navigation of a vehicle over an irregular terrain in Simscape Multibody.
I would like to dynamically modify the terrain height and slope during the simulation.
Is it possible to model a terrain that translates and rotates according to a time-varying input signal, without the terrain applying accelerations or non-physical forces to the bodies in contact with it? simscape MATLAB Answers — New Questions
How to add forced displacement or oscillation into Simscape Multibody?
I’m trying conducting oscillation analysys of multibody dynamics in Simscape Multibody.
In my model, I need to add forced displacement. The figure is an example model that I want to make. In this model, the wall is moving and its displacement is oscillating. I know how to add external force in Simscape Multibody. But what I need is forced displacement like the figure.
The below figure is a model I’m making. In this model, I want to make ‘Base solid’ oscillate without external force.
Please tell me how to add forced displacement.I’m trying conducting oscillation analysys of multibody dynamics in Simscape Multibody.
In my model, I need to add forced displacement. The figure is an example model that I want to make. In this model, the wall is moving and its displacement is oscillating. I know how to add external force in Simscape Multibody. But what I need is forced displacement like the figure.
The below figure is a model I’m making. In this model, I want to make ‘Base solid’ oscillate without external force.
Please tell me how to add forced displacement. I’m trying conducting oscillation analysys of multibody dynamics in Simscape Multibody.
In my model, I need to add forced displacement. The figure is an example model that I want to make. In this model, the wall is moving and its displacement is oscillating. I know how to add external force in Simscape Multibody. But what I need is forced displacement like the figure.
The below figure is a model I’m making. In this model, I want to make ‘Base solid’ oscillate without external force.
Please tell me how to add forced displacement. simscape, multibody MATLAB Answers — New Questions
Verification code not receiving from matlab while creating new account using MY BITS Gmail account
verification code from mathworks matlab not getting while creating new account using MY BITS Gmail accountverification code from mathworks matlab not getting while creating new account using MY BITS Gmail account verification code from mathworks matlab not getting while creating new account using MY BITS Gmail account verification code not receiving from matlab MATLAB Answers — New Questions
How to port the ZCU208 reference design to a custom ZU48DR-based board
I am currently working with a MathWorks reference example and we were able to run this example on the ZCU208 evaluation board, and it works correctly on that platform.
However, we now need to run the same example on our custom hardware board, which is based on a Zynq UltraScale+ RFSOC (ZU48DR) device.
We would like to understand whether it is possible to port the ZCU208 reference design to a custom ZU48DR-based board.
We attempted to create a custom board using the workflow described in the MathWorks documentation:
https://in.mathworks.com/help/soc/ug/create-board-support-framework.html
However, at the very first step, MATLAB reports that there is no available RFSOC board support. It says Only the following boards are supported – Zynq-7000 SoC and Zynq UltraScale+ MPSoC. There is no option available for Zynq UltraScale+ RFSOC.
Could you please clarify if MATLAB currently provides official support for creating custom RFSoC boards? and Is there a recommended method to port the ZCU208 reference workflow to a custom ZU48DR board?
Additionally, we observed that when running the workflow on a ZCU111 board, the rftool configures the clocks(for CLK 104 board) and initializes the RFDC IP.
Is it possible for us to gain access to or enable rftool functionality when using custom RFSOC board?I am currently working with a MathWorks reference example and we were able to run this example on the ZCU208 evaluation board, and it works correctly on that platform.
However, we now need to run the same example on our custom hardware board, which is based on a Zynq UltraScale+ RFSOC (ZU48DR) device.
We would like to understand whether it is possible to port the ZCU208 reference design to a custom ZU48DR-based board.
We attempted to create a custom board using the workflow described in the MathWorks documentation:
https://in.mathworks.com/help/soc/ug/create-board-support-framework.html
However, at the very first step, MATLAB reports that there is no available RFSOC board support. It says Only the following boards are supported – Zynq-7000 SoC and Zynq UltraScale+ MPSoC. There is no option available for Zynq UltraScale+ RFSOC.
Could you please clarify if MATLAB currently provides official support for creating custom RFSoC boards? and Is there a recommended method to port the ZCU208 reference workflow to a custom ZU48DR board?
Additionally, we observed that when running the workflow on a ZCU111 board, the rftool configures the clocks(for CLK 104 board) and initializes the RFDC IP.
Is it possible for us to gain access to or enable rftool functionality when using custom RFSOC board? I am currently working with a MathWorks reference example and we were able to run this example on the ZCU208 evaluation board, and it works correctly on that platform.
However, we now need to run the same example on our custom hardware board, which is based on a Zynq UltraScale+ RFSOC (ZU48DR) device.
We would like to understand whether it is possible to port the ZCU208 reference design to a custom ZU48DR-based board.
We attempted to create a custom board using the workflow described in the MathWorks documentation:
https://in.mathworks.com/help/soc/ug/create-board-support-framework.html
However, at the very first step, MATLAB reports that there is no available RFSOC board support. It says Only the following boards are supported – Zynq-7000 SoC and Zynq UltraScale+ MPSoC. There is no option available for Zynq UltraScale+ RFSOC.
Could you please clarify if MATLAB currently provides official support for creating custom RFSoC boards? and Is there a recommended method to port the ZCU208 reference workflow to a custom ZU48DR board?
Additionally, we observed that when running the workflow on a ZCU111 board, the rftool configures the clocks(for CLK 104 board) and initializes the RFDC IP.
Is it possible for us to gain access to or enable rftool functionality when using custom RFSOC board? custom zu48dr-based board MATLAB Answers — New Questions
Where is the Save icon (not Save As) in a figure (.fig) R2025b Matlab
Only see Save As and cannot find where Save icon is.Only see Save As and cannot find where Save icon is. Only see Save As and cannot find where Save icon is. save a figure MATLAB Answers — New Questions
Unable to get polarbubblechart to show all equal diameter bubbles
I am unable to get "polarbubblechart" to have 3 bubbles all have the same correct size.
All the same size are always are big and unusable. If any one is different the plot is unusable. I need to have all bubbles the same size and controllable. See code below.
What am I missing?
ra = 1
x = pi*ra^2
theta = [0 pi/4 pi/2]
theta = theta.’
rho = [10; 10; 10]
sz = [x x x]
%h.SizeData = sz
h = polarbubblechart(theta,rho,sz)
h.SizeData = sz
ABP = 1
ra = .5
x = pi*ra^2
theta = [0 pi/4 pi/2]
theta = theta.’
rho = [10; 10; 10]
sz = [1 x x]
%h.SizeData = sz
h = polarbubblechart(theta,rho,sz)
h.SizeData = sz
ABP = 1I am unable to get "polarbubblechart" to have 3 bubbles all have the same correct size.
All the same size are always are big and unusable. If any one is different the plot is unusable. I need to have all bubbles the same size and controllable. See code below.
What am I missing?
ra = 1
x = pi*ra^2
theta = [0 pi/4 pi/2]
theta = theta.’
rho = [10; 10; 10]
sz = [x x x]
%h.SizeData = sz
h = polarbubblechart(theta,rho,sz)
h.SizeData = sz
ABP = 1
ra = .5
x = pi*ra^2
theta = [0 pi/4 pi/2]
theta = theta.’
rho = [10; 10; 10]
sz = [1 x x]
%h.SizeData = sz
h = polarbubblechart(theta,rho,sz)
h.SizeData = sz
ABP = 1 I am unable to get "polarbubblechart" to have 3 bubbles all have the same correct size.
All the same size are always are big and unusable. If any one is different the plot is unusable. I need to have all bubbles the same size and controllable. See code below.
What am I missing?
ra = 1
x = pi*ra^2
theta = [0 pi/4 pi/2]
theta = theta.’
rho = [10; 10; 10]
sz = [x x x]
%h.SizeData = sz
h = polarbubblechart(theta,rho,sz)
h.SizeData = sz
ABP = 1
ra = .5
x = pi*ra^2
theta = [0 pi/4 pi/2]
theta = theta.’
rho = [10; 10; 10]
sz = [1 x x]
%h.SizeData = sz
h = polarbubblechart(theta,rho,sz)
h.SizeData = sz
ABP = 1 polarbubblechart, size MATLAB Answers — New Questions
Reliably resize uifigure – sometimes set Position is ignored under test automation
Hi,
I’m facing a strange issue, where resizing of a uifigure doesn’t work consistently under testautomation stress.
Maybe someone has a tip for me, is there a better way to ensure that fig.Postion = [something] is visually applied, than drawnow/pause?
I have set of complicated dialogs, where frames needs to be extended to accomodate additional controls, when user clicks something. Everything works OK for manual testing, but starts failing on test automation.
I have a class object, representing the dialog, and it has property "mainFigure" – uifigure. For resizing of it (extra space on the lower part) I’ve implemented method
function pos = increaseMainFigureHeight(obj, increase)
pos = obj.mainFigure.Position;
% move bottom
pos(2) = pos(2) – increase;
% and increase the height
pos(4) = pos(4) + increase;
obj.mainFigure.Position = pos; <<<
% Flush callbacks and allow layout/window to settle before asserting position
desiredPos = pos;
for k = 1:60
drawnow;
if isequal(obj.mainFigure.Position, desiredPos) <<<<< this read may return different value!
disp([‘increase ok: ‘ num2str(k)]);
break;
end
pause(0.05);
end
if k>=60
Messaging.debug(‘Figure height update not solved in 60 rounds’, level=Messaging.Warning);
end
end
And very similar for decrease the height.
Under manual conditions the "disp([‘increase ok: ‘ num2str(k)]);" prints always 1 – after setting new positions and drawnow, reading of the position will correspond to the positions, which were just set!
However, as soon as I get it under testautomation:
classdef ReusableDialogTest < matlab.unittest.TestCase
methods (Test)
function testIncreaseDecreaseMainFigureHeight(testCase)
dlg = dialogs.AIConfigDialog(); % Just create some dialog, inherited from ReusableDialog
clp = onCleanup(@() delete(dlg));
increaseSize = 100;
initialPos = dlg.mainFigure.Position;
extendedPosition = initialPos;
extendedPosition(2) = initialPos(2) – increaseSize;
extendedPosition(4) = initialPos(4) + increaseSize;
for repeat = 1:20
dlg.increaseMainFigureHeight(increaseSize);
testCase.assertEqual(dlg.mainFigure.Position, extendedPosition);
dlg.decreaseMainFigureHeight(increaseSize);
testCase.assertEqual(dlg.mainFigure.Position, initialPos);
end
end
end
end
I’m starting getting problems.
Note: I’ve inserted the loop for 20 repetitions, just to make the issue more visible.
Typical output for running the test will look like:
Running ReusableDialogTest
Setting up ReusableDialogTest
Done setting up ReusableDialogTest in 0 seconds
Running ReusableDialogTest/testIncreaseDecreaseMainFigureHeight
increase ok: 3
decrease ok: 1
increase ok: 2
decrease ok: 1
increase ok: 2
decrease ok: 2
…
So, sometimes several rounds of drawnow/pause are required.
But sometimes it stucks completely. In following case decrease didn’t succeed with 60 hops of drawnow/pause:
Running ReusableDialogTest
Setting up ReusableDialogTest
Done setting up ReusableDialogTest in 0 seconds
Running ReusableDialogTest/testIncreaseDecreaseMainFigureHeight
increase ok: 3
Warning: Figure height update not solved in 60 rounds
================================================================================
Assertion failed in ReusableDialogTest/testIncreaseDecreaseMainFigureHeight and it did not run to completion.
———————
Framework Diagnostic:
———————
assertEqual failed.
–> The numeric values are not equal using "isequaln".
–> Failure table:
Index Actual Expected Error RelativeError
_____ ______ ________ _____ __________________
2 478 578 -100 -0.173010380622837
4 252 152 100 0.657894736842105
Actual Value:
729 478 583 252
Expected Value:
729 578 583 152
——————
Stack Information:Hi,
I’m facing a strange issue, where resizing of a uifigure doesn’t work consistently under testautomation stress.
Maybe someone has a tip for me, is there a better way to ensure that fig.Postion = [something] is visually applied, than drawnow/pause?
I have set of complicated dialogs, where frames needs to be extended to accomodate additional controls, when user clicks something. Everything works OK for manual testing, but starts failing on test automation.
I have a class object, representing the dialog, and it has property "mainFigure" – uifigure. For resizing of it (extra space on the lower part) I’ve implemented method
function pos = increaseMainFigureHeight(obj, increase)
pos = obj.mainFigure.Position;
% move bottom
pos(2) = pos(2) – increase;
% and increase the height
pos(4) = pos(4) + increase;
obj.mainFigure.Position = pos; <<<
% Flush callbacks and allow layout/window to settle before asserting position
desiredPos = pos;
for k = 1:60
drawnow;
if isequal(obj.mainFigure.Position, desiredPos) <<<<< this read may return different value!
disp([‘increase ok: ‘ num2str(k)]);
break;
end
pause(0.05);
end
if k>=60
Messaging.debug(‘Figure height update not solved in 60 rounds’, level=Messaging.Warning);
end
end
And very similar for decrease the height.
Under manual conditions the "disp([‘increase ok: ‘ num2str(k)]);" prints always 1 – after setting new positions and drawnow, reading of the position will correspond to the positions, which were just set!
However, as soon as I get it under testautomation:
classdef ReusableDialogTest < matlab.unittest.TestCase
methods (Test)
function testIncreaseDecreaseMainFigureHeight(testCase)
dlg = dialogs.AIConfigDialog(); % Just create some dialog, inherited from ReusableDialog
clp = onCleanup(@() delete(dlg));
increaseSize = 100;
initialPos = dlg.mainFigure.Position;
extendedPosition = initialPos;
extendedPosition(2) = initialPos(2) – increaseSize;
extendedPosition(4) = initialPos(4) + increaseSize;
for repeat = 1:20
dlg.increaseMainFigureHeight(increaseSize);
testCase.assertEqual(dlg.mainFigure.Position, extendedPosition);
dlg.decreaseMainFigureHeight(increaseSize);
testCase.assertEqual(dlg.mainFigure.Position, initialPos);
end
end
end
end
I’m starting getting problems.
Note: I’ve inserted the loop for 20 repetitions, just to make the issue more visible.
Typical output for running the test will look like:
Running ReusableDialogTest
Setting up ReusableDialogTest
Done setting up ReusableDialogTest in 0 seconds
Running ReusableDialogTest/testIncreaseDecreaseMainFigureHeight
increase ok: 3
decrease ok: 1
increase ok: 2
decrease ok: 1
increase ok: 2
decrease ok: 2
…
So, sometimes several rounds of drawnow/pause are required.
But sometimes it stucks completely. In following case decrease didn’t succeed with 60 hops of drawnow/pause:
Running ReusableDialogTest
Setting up ReusableDialogTest
Done setting up ReusableDialogTest in 0 seconds
Running ReusableDialogTest/testIncreaseDecreaseMainFigureHeight
increase ok: 3
Warning: Figure height update not solved in 60 rounds
================================================================================
Assertion failed in ReusableDialogTest/testIncreaseDecreaseMainFigureHeight and it did not run to completion.
———————
Framework Diagnostic:
———————
assertEqual failed.
–> The numeric values are not equal using "isequaln".
–> Failure table:
Index Actual Expected Error RelativeError
_____ ______ ________ _____ __________________
2 478 578 -100 -0.173010380622837
4 252 152 100 0.657894736842105
Actual Value:
729 478 583 252
Expected Value:
729 578 583 152
——————
Stack Information: Hi,
I’m facing a strange issue, where resizing of a uifigure doesn’t work consistently under testautomation stress.
Maybe someone has a tip for me, is there a better way to ensure that fig.Postion = [something] is visually applied, than drawnow/pause?
I have set of complicated dialogs, where frames needs to be extended to accomodate additional controls, when user clicks something. Everything works OK for manual testing, but starts failing on test automation.
I have a class object, representing the dialog, and it has property "mainFigure" – uifigure. For resizing of it (extra space on the lower part) I’ve implemented method
function pos = increaseMainFigureHeight(obj, increase)
pos = obj.mainFigure.Position;
% move bottom
pos(2) = pos(2) – increase;
% and increase the height
pos(4) = pos(4) + increase;
obj.mainFigure.Position = pos; <<<
% Flush callbacks and allow layout/window to settle before asserting position
desiredPos = pos;
for k = 1:60
drawnow;
if isequal(obj.mainFigure.Position, desiredPos) <<<<< this read may return different value!
disp([‘increase ok: ‘ num2str(k)]);
break;
end
pause(0.05);
end
if k>=60
Messaging.debug(‘Figure height update not solved in 60 rounds’, level=Messaging.Warning);
end
end
And very similar for decrease the height.
Under manual conditions the "disp([‘increase ok: ‘ num2str(k)]);" prints always 1 – after setting new positions and drawnow, reading of the position will correspond to the positions, which were just set!
However, as soon as I get it under testautomation:
classdef ReusableDialogTest < matlab.unittest.TestCase
methods (Test)
function testIncreaseDecreaseMainFigureHeight(testCase)
dlg = dialogs.AIConfigDialog(); % Just create some dialog, inherited from ReusableDialog
clp = onCleanup(@() delete(dlg));
increaseSize = 100;
initialPos = dlg.mainFigure.Position;
extendedPosition = initialPos;
extendedPosition(2) = initialPos(2) – increaseSize;
extendedPosition(4) = initialPos(4) + increaseSize;
for repeat = 1:20
dlg.increaseMainFigureHeight(increaseSize);
testCase.assertEqual(dlg.mainFigure.Position, extendedPosition);
dlg.decreaseMainFigureHeight(increaseSize);
testCase.assertEqual(dlg.mainFigure.Position, initialPos);
end
end
end
end
I’m starting getting problems.
Note: I’ve inserted the loop for 20 repetitions, just to make the issue more visible.
Typical output for running the test will look like:
Running ReusableDialogTest
Setting up ReusableDialogTest
Done setting up ReusableDialogTest in 0 seconds
Running ReusableDialogTest/testIncreaseDecreaseMainFigureHeight
increase ok: 3
decrease ok: 1
increase ok: 2
decrease ok: 1
increase ok: 2
decrease ok: 2
…
So, sometimes several rounds of drawnow/pause are required.
But sometimes it stucks completely. In following case decrease didn’t succeed with 60 hops of drawnow/pause:
Running ReusableDialogTest
Setting up ReusableDialogTest
Done setting up ReusableDialogTest in 0 seconds
Running ReusableDialogTest/testIncreaseDecreaseMainFigureHeight
increase ok: 3
Warning: Figure height update not solved in 60 rounds
================================================================================
Assertion failed in ReusableDialogTest/testIncreaseDecreaseMainFigureHeight and it did not run to completion.
———————
Framework Diagnostic:
———————
assertEqual failed.
–> The numeric values are not equal using "isequaln".
–> Failure table:
Index Actual Expected Error RelativeError
_____ ______ ________ _____ __________________
2 478 578 -100 -0.173010380622837
4 252 152 100 0.657894736842105
Actual Value:
729 478 583 252
Expected Value:
729 578 583 152
——————
Stack Information: matlab gui, matlab, gui MATLAB Answers — New Questions
How do I include a header file in MATLAB code?
I’m quite new to MATLAB and I’m trying to make a header file and include it in my MATLAB code. The header file contains a lot of constants and calculations that would be needed in the main code. I’m not sure first of all though how to save the header file, (should it be .m?) and also what’s the line of code needed to include it in a MATLAB code. I’m only getting answers for including C/C++ header files in MATLAB.
Apologies if this is a really basic question!I’m quite new to MATLAB and I’m trying to make a header file and include it in my MATLAB code. The header file contains a lot of constants and calculations that would be needed in the main code. I’m not sure first of all though how to save the header file, (should it be .m?) and also what’s the line of code needed to include it in a MATLAB code. I’m only getting answers for including C/C++ header files in MATLAB.
Apologies if this is a really basic question! I’m quite new to MATLAB and I’m trying to make a header file and include it in my MATLAB code. The header file contains a lot of constants and calculations that would be needed in the main code. I’m not sure first of all though how to save the header file, (should it be .m?) and also what’s the line of code needed to include it in a MATLAB code. I’m only getting answers for including C/C++ header files in MATLAB.
Apologies if this is a really basic question! header files, matlab, extension MATLAB Answers — New Questions
Exporting a live script as a pdf renders tables with an inconsistent format
Hi everyone,
I’m trying to export a live script to a PDF for one of my assignments, but the format of tables that MATLAB renders is inconsistent. With some tables, each numerical value is displayed on one line, while with others, the last digit of the number is split on a second line within the cell. In both cases, the table does not fill the entire page space. I see that I can adjust the column widths manually in the live script, but I was wondering if there is a more succinct way to render the tables so that the numbers are not split across multiple lines.
Attached are screenshots of the correct and incorrectly formatted tables, as well as my export settings.
Any help is appreciated.Hi everyone,
I’m trying to export a live script to a PDF for one of my assignments, but the format of tables that MATLAB renders is inconsistent. With some tables, each numerical value is displayed on one line, while with others, the last digit of the number is split on a second line within the cell. In both cases, the table does not fill the entire page space. I see that I can adjust the column widths manually in the live script, but I was wondering if there is a more succinct way to render the tables so that the numbers are not split across multiple lines.
Attached are screenshots of the correct and incorrectly formatted tables, as well as my export settings.
Any help is appreciated. Hi everyone,
I’m trying to export a live script to a PDF for one of my assignments, but the format of tables that MATLAB renders is inconsistent. With some tables, each numerical value is displayed on one line, while with others, the last digit of the number is split on a second line within the cell. In both cases, the table does not fill the entire page space. I see that I can adjust the column widths manually in the live script, but I was wondering if there is a more succinct way to render the tables so that the numbers are not split across multiple lines.
Attached are screenshots of the correct and incorrectly formatted tables, as well as my export settings.
Any help is appreciated. live script, table, linux, pdf, formatting, rendering, export MATLAB Answers — New Questions
MATLAB 2025b not launching
I recently did a firmware update on my linux machine and after that I am not able to launch MATLAB 2025b.
This is the error I get:
MathWorks Licensing Error 9
A licensing error occurred while trying to use MATLAB.
The host ID ‘843a5b57c8e7’ in the license file does not match your computer’s host ID: c0a810c2b168.
To resolve this issue, reactivate your license.
For help with this issue, see this support article:
https://www.mathworks.com/support/lme/9
Details for Support
Feature: MATLAB
License: /home/srikar-k/.matlab/R2025b_licenses:/usr/local/MATLAB/R2025b/licenses/license.dat:/usr/local/MATLAB/R2025b/licenses/license_srikar-k-Dell-Pro-Max-16-Premium-MA16250_41282735_13252145_R2025b.lic
Error Code: -9.2
Unable to launch MVM server: License Error: Licensing shutdownI recently did a firmware update on my linux machine and after that I am not able to launch MATLAB 2025b.
This is the error I get:
MathWorks Licensing Error 9
A licensing error occurred while trying to use MATLAB.
The host ID ‘843a5b57c8e7’ in the license file does not match your computer’s host ID: c0a810c2b168.
To resolve this issue, reactivate your license.
For help with this issue, see this support article:
https://www.mathworks.com/support/lme/9
Details for Support
Feature: MATLAB
License: /home/srikar-k/.matlab/R2025b_licenses:/usr/local/MATLAB/R2025b/licenses/license.dat:/usr/local/MATLAB/R2025b/licenses/license_srikar-k-Dell-Pro-Max-16-Premium-MA16250_41282735_13252145_R2025b.lic
Error Code: -9.2
Unable to launch MVM server: License Error: Licensing shutdown I recently did a firmware update on my linux machine and after that I am not able to launch MATLAB 2025b.
This is the error I get:
MathWorks Licensing Error 9
A licensing error occurred while trying to use MATLAB.
The host ID ‘843a5b57c8e7’ in the license file does not match your computer’s host ID: c0a810c2b168.
To resolve this issue, reactivate your license.
For help with this issue, see this support article:
https://www.mathworks.com/support/lme/9
Details for Support
Feature: MATLAB
License: /home/srikar-k/.matlab/R2025b_licenses:/usr/local/MATLAB/R2025b/licenses/license.dat:/usr/local/MATLAB/R2025b/licenses/license_srikar-k-Dell-Pro-Max-16-Premium-MA16250_41282735_13252145_R2025b.lic
Error Code: -9.2
Unable to launch MVM server: License Error: Licensing shutdown license MATLAB Answers — New Questions
why is my for loop not working?
y=@(x) x^2-4;
x1=input(‘Enter the value of x1:’);
x2=input(‘Enter the value of x2:’);
x3=input(‘Enter the value of x3:’);
for i=1:100
L1=(x2-x3)/(x3-x1);
xf=x3+L1*(x3-x1);
y1=abs(y(x1));
y2= abs(y(x2));
y3=abs(y(x3));
yf=abs(y(xf));
ynext=sort([y1 y2 y3 yf]);
if y1==max(ynext)
x1=xf;
elseif y2==max(ynext)
x2=xf;
else
x3=xf;
end
if y(xf)<10^-10
break
end
end
fprintf(‘the root: %fn the number of iterations: %dn’,xf,i)y=@(x) x^2-4;
x1=input(‘Enter the value of x1:’);
x2=input(‘Enter the value of x2:’);
x3=input(‘Enter the value of x3:’);
for i=1:100
L1=(x2-x3)/(x3-x1);
xf=x3+L1*(x3-x1);
y1=abs(y(x1));
y2= abs(y(x2));
y3=abs(y(x3));
yf=abs(y(xf));
ynext=sort([y1 y2 y3 yf]);
if y1==max(ynext)
x1=xf;
elseif y2==max(ynext)
x2=xf;
else
x3=xf;
end
if y(xf)<10^-10
break
end
end
fprintf(‘the root: %fn the number of iterations: %dn’,xf,i) y=@(x) x^2-4;
x1=input(‘Enter the value of x1:’);
x2=input(‘Enter the value of x2:’);
x3=input(‘Enter the value of x3:’);
for i=1:100
L1=(x2-x3)/(x3-x1);
xf=x3+L1*(x3-x1);
y1=abs(y(x1));
y2= abs(y(x2));
y3=abs(y(x3));
yf=abs(y(xf));
ynext=sort([y1 y2 y3 yf]);
if y1==max(ynext)
x1=xf;
elseif y2==max(ynext)
x2=xf;
else
x3=xf;
end
if y(xf)<10^-10
break
end
end
fprintf(‘the root: %fn the number of iterations: %dn’,xf,i) for loop MATLAB Answers — New Questions
How can I do one-hot encoding in MATLAB?
I would like to perform one-hot encoding on the vector [1 7 10 9 8 6]’ with 10 classes (numbers 1 to 10). The resulting 6×10 matrix should have a 1×10 vector in place of each number, with "1" at the position corresponding to the number and "0" at all other positions.I would like to perform one-hot encoding on the vector [1 7 10 9 8 6]’ with 10 classes (numbers 1 to 10). The resulting 6×10 matrix should have a 1×10 vector in place of each number, with "1" at the position corresponding to the number and "0" at all other positions. I would like to perform one-hot encoding on the vector [1 7 10 9 8 6]’ with 10 classes (numbers 1 to 10). The resulting 6×10 matrix should have a 1×10 vector in place of each number, with "1" at the position corresponding to the number and "0" at all other positions. one, hot, encoding, corresponding, number, 1, 0 MATLAB Answers — New Questions
USRP B210 GPSDO time?
I am working on a project using both the USRP B210 and the compatible GPSDO. I am time-stamping pulses detected when going through the SDR. Is there a way through either MATLAB or Simulink that I can pull the GPS timestamps from the SDR packets it streams to the PC? I already have the USRP Communications toolbox installed. I have gone through the toolbox documentation and it appears to have no information regarding parsing the packets. The Simulink block appears to only provide the sample of the signal, and not the timestamp of that sample.I am working on a project using both the USRP B210 and the compatible GPSDO. I am time-stamping pulses detected when going through the SDR. Is there a way through either MATLAB or Simulink that I can pull the GPS timestamps from the SDR packets it streams to the PC? I already have the USRP Communications toolbox installed. I have gone through the toolbox documentation and it appears to have no information regarding parsing the packets. The Simulink block appears to only provide the sample of the signal, and not the timestamp of that sample. I am working on a project using both the USRP B210 and the compatible GPSDO. I am time-stamping pulses detected when going through the SDR. Is there a way through either MATLAB or Simulink that I can pull the GPS timestamps from the SDR packets it streams to the PC? I already have the USRP Communications toolbox installed. I have gone through the toolbox documentation and it appears to have no information regarding parsing the packets. The Simulink block appears to only provide the sample of the signal, and not the timestamp of that sample. ettus, usrp, time, gps MATLAB Answers — New Questions
Convert non inlined s-function to inlined with wrapper
Hello!
I’m trying to reproduce the model described in this article: https://nl.mathworks.com/help/rtw/ug/write-wrapper-s-function-and-tlc-files.html#f53147
I’ve created the non inlined model. This model take an array of numbers and multuply by 2 each element.
The core function is the flowing:
static void mdlOutputs(SimStruct *S, int_T tid)
{
InputPtrsType uPtrs = ssGetInputPortSignalPtrs(S, 0);
uint8_T *y = (uint8_T *)ssGetOutputPortSignal(S, 0);
int_T width = ssGetOutputPortWidth(S, 0);
for (int_T i = 0; i < width; i++) {
y[i] = 2 * (*(uint8_T *)uPtrs[i]);
}
}
I’ve make a simple model and compile the *.c file with command:
mex times_two.c
The model is in the Noninlined.zip
Now; with the help of the article (https://nl.mathworks.com/help/rtw/ug/write-wrapper-s-function-and-tlc-files.html#f53147) I’ve created a wrapsfcn.tlc:
%%This code is the TLC file wrapsfcn.tlc that inlines wrapsfcn.c:
%% File : wrapsfcn.tlc
%% Abstract:
%% Example inlined tlc file for S-function wrapsfcn.c
%%
%implements "wrapsfcn" "C"
%% Function: BlockTypeSetup ====================================================
%% Abstract:
%% Create function prototype in model.h as:
%% "extern real_T times_two(real_T u);"
%%
%function BlockTypeSetup(block, system) void
%openfile buffer
extern real_T times_two(real_T u); /* This line is placed in wrapper.h */
%closefile buffer
%<LibCacheFunctionPrototype(buffer)>
%endfunction %% BlockTypeSetup
%% Function: Outputs ===========================================================
%% Abstract:
%% y = times_two( u );
%%
%function Outputs(block, system) Output
/* %<Type> Block: %<Name> */
%assign u = LibBlockInputSignal( 0, "i", "", 0)
%assign y = LibBlockOutputSignal(0, "i", "", 0)
%% PROVIDE THE CALLING STATEMENT FOR "algorithm"
%% The following line is expanded and placed in mdlOutputs within wrapper.c
{
%assign u = LibBlockInputSignal( 0, "i", "", 0)
%assign y = LibBlockOutputSignal(0, "i", "", 0)
for (i = 0; i < %<LibBlockInputSignalWidth(0)>; i++) {
%<y> = times_two(%<u>);
}
}
%endfunction %% Outputs
and the file times_two.c:
#ifdef MATLAB_MEX_FILE
#include "tmwtypes.h"
#else
#include "rtwtypes.h"
#endif
real_T times_two(real_T u)
{
return(2.0 * u);
}
I’ve made a model (see Inlined.zip) but the Simulink didn’t detect the function real_T times_two(real_T u)
Error in S-function ‘inlined_wrapsfcn/S-Function’: S-Function ‘wrapsfcn’ does not exist
From the article I don’t understand what should be the exact content of the files wrapper.c and wrapper.h. It may be the reason why the inlined model didn’t work.
Could you please explain me that steps I’ve missed?Hello!
I’m trying to reproduce the model described in this article: https://nl.mathworks.com/help/rtw/ug/write-wrapper-s-function-and-tlc-files.html#f53147
I’ve created the non inlined model. This model take an array of numbers and multuply by 2 each element.
The core function is the flowing:
static void mdlOutputs(SimStruct *S, int_T tid)
{
InputPtrsType uPtrs = ssGetInputPortSignalPtrs(S, 0);
uint8_T *y = (uint8_T *)ssGetOutputPortSignal(S, 0);
int_T width = ssGetOutputPortWidth(S, 0);
for (int_T i = 0; i < width; i++) {
y[i] = 2 * (*(uint8_T *)uPtrs[i]);
}
}
I’ve make a simple model and compile the *.c file with command:
mex times_two.c
The model is in the Noninlined.zip
Now; with the help of the article (https://nl.mathworks.com/help/rtw/ug/write-wrapper-s-function-and-tlc-files.html#f53147) I’ve created a wrapsfcn.tlc:
%%This code is the TLC file wrapsfcn.tlc that inlines wrapsfcn.c:
%% File : wrapsfcn.tlc
%% Abstract:
%% Example inlined tlc file for S-function wrapsfcn.c
%%
%implements "wrapsfcn" "C"
%% Function: BlockTypeSetup ====================================================
%% Abstract:
%% Create function prototype in model.h as:
%% "extern real_T times_two(real_T u);"
%%
%function BlockTypeSetup(block, system) void
%openfile buffer
extern real_T times_two(real_T u); /* This line is placed in wrapper.h */
%closefile buffer
%<LibCacheFunctionPrototype(buffer)>
%endfunction %% BlockTypeSetup
%% Function: Outputs ===========================================================
%% Abstract:
%% y = times_two( u );
%%
%function Outputs(block, system) Output
/* %<Type> Block: %<Name> */
%assign u = LibBlockInputSignal( 0, "i", "", 0)
%assign y = LibBlockOutputSignal(0, "i", "", 0)
%% PROVIDE THE CALLING STATEMENT FOR "algorithm"
%% The following line is expanded and placed in mdlOutputs within wrapper.c
{
%assign u = LibBlockInputSignal( 0, "i", "", 0)
%assign y = LibBlockOutputSignal(0, "i", "", 0)
for (i = 0; i < %<LibBlockInputSignalWidth(0)>; i++) {
%<y> = times_two(%<u>);
}
}
%endfunction %% Outputs
and the file times_two.c:
#ifdef MATLAB_MEX_FILE
#include "tmwtypes.h"
#else
#include "rtwtypes.h"
#endif
real_T times_two(real_T u)
{
return(2.0 * u);
}
I’ve made a model (see Inlined.zip) but the Simulink didn’t detect the function real_T times_two(real_T u)
Error in S-function ‘inlined_wrapsfcn/S-Function’: S-Function ‘wrapsfcn’ does not exist
From the article I don’t understand what should be the exact content of the files wrapper.c and wrapper.h. It may be the reason why the inlined model didn’t work.
Could you please explain me that steps I’ve missed? Hello!
I’m trying to reproduce the model described in this article: https://nl.mathworks.com/help/rtw/ug/write-wrapper-s-function-and-tlc-files.html#f53147
I’ve created the non inlined model. This model take an array of numbers and multuply by 2 each element.
The core function is the flowing:
static void mdlOutputs(SimStruct *S, int_T tid)
{
InputPtrsType uPtrs = ssGetInputPortSignalPtrs(S, 0);
uint8_T *y = (uint8_T *)ssGetOutputPortSignal(S, 0);
int_T width = ssGetOutputPortWidth(S, 0);
for (int_T i = 0; i < width; i++) {
y[i] = 2 * (*(uint8_T *)uPtrs[i]);
}
}
I’ve make a simple model and compile the *.c file with command:
mex times_two.c
The model is in the Noninlined.zip
Now; with the help of the article (https://nl.mathworks.com/help/rtw/ug/write-wrapper-s-function-and-tlc-files.html#f53147) I’ve created a wrapsfcn.tlc:
%%This code is the TLC file wrapsfcn.tlc that inlines wrapsfcn.c:
%% File : wrapsfcn.tlc
%% Abstract:
%% Example inlined tlc file for S-function wrapsfcn.c
%%
%implements "wrapsfcn" "C"
%% Function: BlockTypeSetup ====================================================
%% Abstract:
%% Create function prototype in model.h as:
%% "extern real_T times_two(real_T u);"
%%
%function BlockTypeSetup(block, system) void
%openfile buffer
extern real_T times_two(real_T u); /* This line is placed in wrapper.h */
%closefile buffer
%<LibCacheFunctionPrototype(buffer)>
%endfunction %% BlockTypeSetup
%% Function: Outputs ===========================================================
%% Abstract:
%% y = times_two( u );
%%
%function Outputs(block, system) Output
/* %<Type> Block: %<Name> */
%assign u = LibBlockInputSignal( 0, "i", "", 0)
%assign y = LibBlockOutputSignal(0, "i", "", 0)
%% PROVIDE THE CALLING STATEMENT FOR "algorithm"
%% The following line is expanded and placed in mdlOutputs within wrapper.c
{
%assign u = LibBlockInputSignal( 0, "i", "", 0)
%assign y = LibBlockOutputSignal(0, "i", "", 0)
for (i = 0; i < %<LibBlockInputSignalWidth(0)>; i++) {
%<y> = times_two(%<u>);
}
}
%endfunction %% Outputs
and the file times_two.c:
#ifdef MATLAB_MEX_FILE
#include "tmwtypes.h"
#else
#include "rtwtypes.h"
#endif
real_T times_two(real_T u)
{
return(2.0 * u);
}
I’ve made a model (see Inlined.zip) but the Simulink didn’t detect the function real_T times_two(real_T u)
Error in S-function ‘inlined_wrapsfcn/S-Function’: S-Function ‘wrapsfcn’ does not exist
From the article I don’t understand what should be the exact content of the files wrapper.c and wrapper.h. It may be the reason why the inlined model didn’t work.
Could you please explain me that steps I’ve missed? s-function, mex, tlc, wrapper, inline MATLAB Answers — New Questions
How to TX/RX using 2 boards with the “HW/SW Co-Design QPSK Transmit and Receive Using Analog Devices AD9361/AD9364” example
Hello,
I am trying to transmit and receive using 2 different supported boards (2x ZEDBOARD + 2x FMCOMMS3) using following example:
https://in.mathworks.com/help/soc/ug/hw-sw-co-design-qpsk-transmit-and-receive-using-analog-devices-ad9361-ad9364.html
I have succesfully compiled the simulation, programmed the board via HDL Coder and HDL Workflow Advisor and transmitted and received with ease using one board. However, when trying to use 2 boards, I do not know the procedure I need to follow for a successful TX/RX over air. I am not able to see the other board’s data at the receiver. I do not receive anything.
My approach was the following:
– I configured both ZEDBOARDs with the bitstream of the example.
– I attached one antenna to the TX port of the TX FMCOMMS3 and one antenna to the RX port of the RX FMCOMMS3.
– I disabled on one end the AD936x transmitter system and on the other the AD936x receiver system.
– The systems can be seen in the attached images.
– The UDP receive model was running on the receiver side.
The result: I do not see any bits coming into the RX side.
Anybody has some expertise in this? Maybe there are other examples which I have not discovered yet that address this scenario…
Any help would be welcome. Thank you in advance
—————————————————————————————-
RX Side:
TX side:
UDP Model:Hello,
I am trying to transmit and receive using 2 different supported boards (2x ZEDBOARD + 2x FMCOMMS3) using following example:
https://in.mathworks.com/help/soc/ug/hw-sw-co-design-qpsk-transmit-and-receive-using-analog-devices-ad9361-ad9364.html
I have succesfully compiled the simulation, programmed the board via HDL Coder and HDL Workflow Advisor and transmitted and received with ease using one board. However, when trying to use 2 boards, I do not know the procedure I need to follow for a successful TX/RX over air. I am not able to see the other board’s data at the receiver. I do not receive anything.
My approach was the following:
– I configured both ZEDBOARDs with the bitstream of the example.
– I attached one antenna to the TX port of the TX FMCOMMS3 and one antenna to the RX port of the RX FMCOMMS3.
– I disabled on one end the AD936x transmitter system and on the other the AD936x receiver system.
– The systems can be seen in the attached images.
– The UDP receive model was running on the receiver side.
The result: I do not see any bits coming into the RX side.
Anybody has some expertise in this? Maybe there are other examples which I have not discovered yet that address this scenario…
Any help would be welcome. Thank you in advance
—————————————————————————————-
RX Side:
TX side:
UDP Model: Hello,
I am trying to transmit and receive using 2 different supported boards (2x ZEDBOARD + 2x FMCOMMS3) using following example:
https://in.mathworks.com/help/soc/ug/hw-sw-co-design-qpsk-transmit-and-receive-using-analog-devices-ad9361-ad9364.html
I have succesfully compiled the simulation, programmed the board via HDL Coder and HDL Workflow Advisor and transmitted and received with ease using one board. However, when trying to use 2 boards, I do not know the procedure I need to follow for a successful TX/RX over air. I am not able to see the other board’s data at the receiver. I do not receive anything.
My approach was the following:
– I configured both ZEDBOARDs with the bitstream of the example.
– I attached one antenna to the TX port of the TX FMCOMMS3 and one antenna to the RX port of the RX FMCOMMS3.
– I disabled on one end the AD936x transmitter system and on the other the AD936x receiver system.
– The systems can be seen in the attached images.
– The UDP receive model was running on the receiver side.
The result: I do not see any bits coming into the RX side.
Anybody has some expertise in this? Maybe there are other examples which I have not discovered yet that address this scenario…
Any help would be welcome. Thank you in advance
—————————————————————————————-
RX Side:
TX side:
UDP Model: simulink, ad9361, zedboard, fmcomms3 MATLAB Answers — New Questions
about the use of the fullfact function
I want use the function of fullfact in R2025b, but there is a note that :fullfact needs Statistics and Machine Learning Toolbox。
I installed fullfact Statistics and Machine Learning Toolbox by checking the Add-Ons, but when i check the installation with ver, there is no Statistics and Machine Learning Toolbox,I don’t know why, and how can i use the fullfact.I want use the function of fullfact in R2025b, but there is a note that :fullfact needs Statistics and Machine Learning Toolbox。
I installed fullfact Statistics and Machine Learning Toolbox by checking the Add-Ons, but when i check the installation with ver, there is no Statistics and Machine Learning Toolbox,I don’t know why, and how can i use the fullfact. I want use the function of fullfact in R2025b, but there is a note that :fullfact needs Statistics and Machine Learning Toolbox。
I installed fullfact Statistics and Machine Learning Toolbox by checking the Add-Ons, but when i check the installation with ver, there is no Statistics and Machine Learning Toolbox,I don’t know why, and how can i use the fullfact. fullfact, statistics and machine learning toolbox MATLAB Answers — New Questions
How to export Simulink models (with Stateflow components) to XML ?
Hello,
I would need to know how can I export Simulink models (and some of these latter may also have Stateflow components, such as State Charts etc.) to XML.
I have typed the following MATLAB commands:
modelName = ‘sf_aircraft’ % model of the name without extension
save_system(modelName, ‘xml_model.xml’, ‘ExportToXML’, true)
But I have the following warning :
Warning: The ‘ExportToXML’ option is no longer supported and will be removed in a future release.
And I have also noticed that in the XML file the State Chart component is just mentioned, so basically I cannot see what it contains from the XML file.
So what I would like to ask is if there are other functions or ways that allow Simulink models with State Charts components to be exported in a XML format.
Thanks in advance.Hello,
I would need to know how can I export Simulink models (and some of these latter may also have Stateflow components, such as State Charts etc.) to XML.
I have typed the following MATLAB commands:
modelName = ‘sf_aircraft’ % model of the name without extension
save_system(modelName, ‘xml_model.xml’, ‘ExportToXML’, true)
But I have the following warning :
Warning: The ‘ExportToXML’ option is no longer supported and will be removed in a future release.
And I have also noticed that in the XML file the State Chart component is just mentioned, so basically I cannot see what it contains from the XML file.
So what I would like to ask is if there are other functions or ways that allow Simulink models with State Charts components to be exported in a XML format.
Thanks in advance. Hello,
I would need to know how can I export Simulink models (and some of these latter may also have Stateflow components, such as State Charts etc.) to XML.
I have typed the following MATLAB commands:
modelName = ‘sf_aircraft’ % model of the name without extension
save_system(modelName, ‘xml_model.xml’, ‘ExportToXML’, true)
But I have the following warning :
Warning: The ‘ExportToXML’ option is no longer supported and will be removed in a future release.
And I have also noticed that in the XML file the State Chart component is just mentioned, so basically I cannot see what it contains from the XML file.
So what I would like to ask is if there are other functions or ways that allow Simulink models with State Charts components to be exported in a XML format.
Thanks in advance. simulink, stateflow, xml MATLAB Answers — New Questions
Valid MATLAB Runtime installer not found.
When trying to compile a stand alone ap in ap designer, it throws the error "Valid MATLAB Runtime installer not found". It prompts for MATLAB Runtime installer location. Here is what my IT guy installed:
At C:Program FilesMatlab
R2024b
MATLAB Compiler Runtime
MATLAB Runtime
The IT guy reported that he was unable to add paths to the ENVIRONMENT VARIABLES.
What do I need to do so that I can compile stand alone .exe applications?When trying to compile a stand alone ap in ap designer, it throws the error "Valid MATLAB Runtime installer not found". It prompts for MATLAB Runtime installer location. Here is what my IT guy installed:
At C:Program FilesMatlab
R2024b
MATLAB Compiler Runtime
MATLAB Runtime
The IT guy reported that he was unable to add paths to the ENVIRONMENT VARIABLES.
What do I need to do so that I can compile stand alone .exe applications? When trying to compile a stand alone ap in ap designer, it throws the error "Valid MATLAB Runtime installer not found". It prompts for MATLAB Runtime installer location. Here is what my IT guy installed:
At C:Program FilesMatlab
R2024b
MATLAB Compiler Runtime
MATLAB Runtime
The IT guy reported that he was unable to add paths to the ENVIRONMENT VARIABLES.
What do I need to do so that I can compile stand alone .exe applications? runtime installer path MATLAB Answers — New Questions
how to plot 3d surface maps? interpolation?
Hi All,
i am struggeling to have a correct interpolation (IDW) for 3d surface maps for the spatial analysis of the parameters collected by CTD to plot temperature (as an example). There is something wrong!
any help is very much appreciated
the steps are below:
1- list of mat fiels each of this mat files contains T table inside (screenshot shows).
2- download the mat fiels
3- grid the data from mulitple CTD locations
4- Surface maps with the coastlines
dataDir = ‘/’;
files = dir(fullfile(dataDir, ‘*.mat’));
T_all = table();
for i = 1:length(files)
fname = fullfile(dataDir, files(i).name);
S = load(fname);
if isfield(S,’T’)
Ti = S.T;
Ti.SourceFile = repmat(string(files(i).name), height(Ti), 1);
Tall = [Tall; Ti];
else
warning(‘%s does not contain table T’, files(i).name)
end
end
depth_target = 2.0; % meters
tol = 0.5; % ±0.5 m
Tz = Tall(abs(Tall.Depth_m – depth_target) <= tol, :);
[G, station, date] = findgroups(Tz.Station, Tz.Date);
Tmap = table();
Tmap.Station = station;
Tmap.Date = date;
Tmap.Lat = splitapply(@mean, Tz.Lat, G);
Tmap.Lon = splitapply(@mean, Tz.Lon, G);
Tmap.Temp = splitapply(@mean, Tz.Temp_C, G);
min_map_lon = 35.2;
max_map_lon = 37.2;
min_map_lat = 25.1;
max_map_lat = 27.6;
[LonGrid, LatGrid] = meshgrid( …
linspace(min_map_lon, max_map_lon, 250), …
linspace(min_map_lat, max_map_lat, 250));
TempGrid = griddata( …
Tmap.Lon, Tmap.Lat, Tmap.Temp, …
LonGrid, LatGrid, ‘v4’); % IDW
load RS_bathy_gebgo % longitude, latitude, bathy
orient portrait
figure
hold on
m_proj(‘mercator’, …
‘lon’,[min_map_lon max_map_lon], …
‘lat’,[min_map_lat max_map_lat]);
m_pcolor(longitude, latitude, bathy);
shading interp
colormap(flipud(gray))
caxis([-1200 0])
h = m_pcolor(LonGrid, LatGrid, TempGrid);
set(h,’FaceAlpha’,0.85) % transparency so bathy shows
shading interp
colormap(turbo)
m_usercoast(‘red_sea_f’,’patch’,[0.8 0.8 0.8])
m_grid(‘contour’,’on’,’tickdir’,’out’, …
‘box’,’fancy’,’fontsize’,10, …
‘linewidth’,1,’linestyle’,’–‘);
colorbar
ylabel(‘Latitude’,’fontsize’,16,’fontweight’,’bold’);
xlabel(‘Longitude’,’fontsize’,16,’fontweight’,’bold’);Hi All,
i am struggeling to have a correct interpolation (IDW) for 3d surface maps for the spatial analysis of the parameters collected by CTD to plot temperature (as an example). There is something wrong!
any help is very much appreciated
the steps are below:
1- list of mat fiels each of this mat files contains T table inside (screenshot shows).
2- download the mat fiels
3- grid the data from mulitple CTD locations
4- Surface maps with the coastlines
dataDir = ‘/’;
files = dir(fullfile(dataDir, ‘*.mat’));
T_all = table();
for i = 1:length(files)
fname = fullfile(dataDir, files(i).name);
S = load(fname);
if isfield(S,’T’)
Ti = S.T;
Ti.SourceFile = repmat(string(files(i).name), height(Ti), 1);
Tall = [Tall; Ti];
else
warning(‘%s does not contain table T’, files(i).name)
end
end
depth_target = 2.0; % meters
tol = 0.5; % ±0.5 m
Tz = Tall(abs(Tall.Depth_m – depth_target) <= tol, :);
[G, station, date] = findgroups(Tz.Station, Tz.Date);
Tmap = table();
Tmap.Station = station;
Tmap.Date = date;
Tmap.Lat = splitapply(@mean, Tz.Lat, G);
Tmap.Lon = splitapply(@mean, Tz.Lon, G);
Tmap.Temp = splitapply(@mean, Tz.Temp_C, G);
min_map_lon = 35.2;
max_map_lon = 37.2;
min_map_lat = 25.1;
max_map_lat = 27.6;
[LonGrid, LatGrid] = meshgrid( …
linspace(min_map_lon, max_map_lon, 250), …
linspace(min_map_lat, max_map_lat, 250));
TempGrid = griddata( …
Tmap.Lon, Tmap.Lat, Tmap.Temp, …
LonGrid, LatGrid, ‘v4’); % IDW
load RS_bathy_gebgo % longitude, latitude, bathy
orient portrait
figure
hold on
m_proj(‘mercator’, …
‘lon’,[min_map_lon max_map_lon], …
‘lat’,[min_map_lat max_map_lat]);
m_pcolor(longitude, latitude, bathy);
shading interp
colormap(flipud(gray))
caxis([-1200 0])
h = m_pcolor(LonGrid, LatGrid, TempGrid);
set(h,’FaceAlpha’,0.85) % transparency so bathy shows
shading interp
colormap(turbo)
m_usercoast(‘red_sea_f’,’patch’,[0.8 0.8 0.8])
m_grid(‘contour’,’on’,’tickdir’,’out’, …
‘box’,’fancy’,’fontsize’,10, …
‘linewidth’,1,’linestyle’,’–‘);
colorbar
ylabel(‘Latitude’,’fontsize’,16,’fontweight’,’bold’);
xlabel(‘Longitude’,’fontsize’,16,’fontweight’,’bold’); Hi All,
i am struggeling to have a correct interpolation (IDW) for 3d surface maps for the spatial analysis of the parameters collected by CTD to plot temperature (as an example). There is something wrong!
any help is very much appreciated
the steps are below:
1- list of mat fiels each of this mat files contains T table inside (screenshot shows).
2- download the mat fiels
3- grid the data from mulitple CTD locations
4- Surface maps with the coastlines
dataDir = ‘/’;
files = dir(fullfile(dataDir, ‘*.mat’));
T_all = table();
for i = 1:length(files)
fname = fullfile(dataDir, files(i).name);
S = load(fname);
if isfield(S,’T’)
Ti = S.T;
Ti.SourceFile = repmat(string(files(i).name), height(Ti), 1);
Tall = [Tall; Ti];
else
warning(‘%s does not contain table T’, files(i).name)
end
end
depth_target = 2.0; % meters
tol = 0.5; % ±0.5 m
Tz = Tall(abs(Tall.Depth_m – depth_target) <= tol, :);
[G, station, date] = findgroups(Tz.Station, Tz.Date);
Tmap = table();
Tmap.Station = station;
Tmap.Date = date;
Tmap.Lat = splitapply(@mean, Tz.Lat, G);
Tmap.Lon = splitapply(@mean, Tz.Lon, G);
Tmap.Temp = splitapply(@mean, Tz.Temp_C, G);
min_map_lon = 35.2;
max_map_lon = 37.2;
min_map_lat = 25.1;
max_map_lat = 27.6;
[LonGrid, LatGrid] = meshgrid( …
linspace(min_map_lon, max_map_lon, 250), …
linspace(min_map_lat, max_map_lat, 250));
TempGrid = griddata( …
Tmap.Lon, Tmap.Lat, Tmap.Temp, …
LonGrid, LatGrid, ‘v4’); % IDW
load RS_bathy_gebgo % longitude, latitude, bathy
orient portrait
figure
hold on
m_proj(‘mercator’, …
‘lon’,[min_map_lon max_map_lon], …
‘lat’,[min_map_lat max_map_lat]);
m_pcolor(longitude, latitude, bathy);
shading interp
colormap(flipud(gray))
caxis([-1200 0])
h = m_pcolor(LonGrid, LatGrid, TempGrid);
set(h,’FaceAlpha’,0.85) % transparency so bathy shows
shading interp
colormap(turbo)
m_usercoast(‘red_sea_f’,’patch’,[0.8 0.8 0.8])
m_grid(‘contour’,’on’,’tickdir’,’out’, …
‘box’,’fancy’,’fontsize’,10, …
‘linewidth’,1,’linestyle’,’–‘);
colorbar
ylabel(‘Latitude’,’fontsize’,16,’fontweight’,’bold’);
xlabel(‘Longitude’,’fontsize’,16,’fontweight’,’bold’); interpolation, 3d plots, surface MATLAB Answers — New Questions
Writecell/table to Excel error
Hi all,
I can no longer export data to Excel using writecell/table, because the function crashes due to an import issue :
Error using writetable (line 278)
Error: File: createWorkbook.m Line: 80 Column: 12
Unable to find or import ‘matlab.io.spreadsheet.internal.BookType’.Imported names must end with ‘.*’ or be fully qualified.
No problem in Matlab R2023, as it does not seem to use the same sub-functions.
Regards,
Stéphane.Hi all,
I can no longer export data to Excel using writecell/table, because the function crashes due to an import issue :
Error using writetable (line 278)
Error: File: createWorkbook.m Line: 80 Column: 12
Unable to find or import ‘matlab.io.spreadsheet.internal.BookType’.Imported names must end with ‘.*’ or be fully qualified.
No problem in Matlab R2023, as it does not seem to use the same sub-functions.
Regards,
Stéphane. Hi all,
I can no longer export data to Excel using writecell/table, because the function crashes due to an import issue :
Error using writetable (line 278)
Error: File: createWorkbook.m Line: 80 Column: 12
Unable to find or import ‘matlab.io.spreadsheet.internal.BookType’.Imported names must end with ‘.*’ or be fully qualified.
No problem in Matlab R2023, as it does not seem to use the same sub-functions.
Regards,
Stéphane. booktype, writecell, writetable MATLAB Answers — New Questions









