Author: PuTI
Access to higher resolutions in 48MP USB camera
I am using a 48MP USB camera – this one specifically: https://www.elpcctv.com/elp-48mp-high-resolution-usb-camera-with-varifocal-cs-3610mm-lens-p-443.html
I am using a Macbook Apple M2 (Sequoia 15.6) and thus using the ‘macvideo’ Adaptor … the problem is that although this is a 48MP camera – so a max resolution of 8000×6000 at low FPS, the highest res returned is 3840×2160 (see below). I guess this is because this is a "generic" adaptor?? Is there any way in which I can tap into all of the possible resolutions of this camera using matlab? (I note that the manufacturer says the high res are availabile via a different codec – MJPEG vs YUY2 (8000×6000 @ 5fps MJPEG / 4000×3000 @ 12fps MJPEG
3840×2160 @ 30fps MJPEG) could this be the main issue?
Any pointers greatly appreciated …
Thanks
>> imaqhwinfo(‘macvideo’,1)
ans =
struct with fields:
DefaultFormat: ‘YCbCr422_1920x1080’
DeviceFileSupported: 0
DeviceName: ’48MP USB Camera’
DeviceID: 1
VideoInputConstructor: ‘videoinput(‘macvideo’, 1)’
VideoDeviceConstructor: ‘imaq.VideoDevice(‘macvideo’, 1)’
SupportedFormats: {‘YCbCr422_1280x720’ ‘YCbCr422_1920x1080’ ‘YCbCr422_192x144’ ‘YCbCr422_320x240’ ‘YCbCr422_352x288’ ‘YCbCr422_3840x2160’ ‘YCbCr422_480x360’ ‘YCbCr422_960x540’}
>>I am using a 48MP USB camera – this one specifically: https://www.elpcctv.com/elp-48mp-high-resolution-usb-camera-with-varifocal-cs-3610mm-lens-p-443.html
I am using a Macbook Apple M2 (Sequoia 15.6) and thus using the ‘macvideo’ Adaptor … the problem is that although this is a 48MP camera – so a max resolution of 8000×6000 at low FPS, the highest res returned is 3840×2160 (see below). I guess this is because this is a "generic" adaptor?? Is there any way in which I can tap into all of the possible resolutions of this camera using matlab? (I note that the manufacturer says the high res are availabile via a different codec – MJPEG vs YUY2 (8000×6000 @ 5fps MJPEG / 4000×3000 @ 12fps MJPEG
3840×2160 @ 30fps MJPEG) could this be the main issue?
Any pointers greatly appreciated …
Thanks
>> imaqhwinfo(‘macvideo’,1)
ans =
struct with fields:
DefaultFormat: ‘YCbCr422_1920x1080’
DeviceFileSupported: 0
DeviceName: ’48MP USB Camera’
DeviceID: 1
VideoInputConstructor: ‘videoinput(‘macvideo’, 1)’
VideoDeviceConstructor: ‘imaq.VideoDevice(‘macvideo’, 1)’
SupportedFormats: {‘YCbCr422_1280x720’ ‘YCbCr422_1920x1080’ ‘YCbCr422_192x144’ ‘YCbCr422_320x240’ ‘YCbCr422_352x288’ ‘YCbCr422_3840x2160’ ‘YCbCr422_480x360’ ‘YCbCr422_960x540’}
>> I am using a 48MP USB camera – this one specifically: https://www.elpcctv.com/elp-48mp-high-resolution-usb-camera-with-varifocal-cs-3610mm-lens-p-443.html
I am using a Macbook Apple M2 (Sequoia 15.6) and thus using the ‘macvideo’ Adaptor … the problem is that although this is a 48MP camera – so a max resolution of 8000×6000 at low FPS, the highest res returned is 3840×2160 (see below). I guess this is because this is a "generic" adaptor?? Is there any way in which I can tap into all of the possible resolutions of this camera using matlab? (I note that the manufacturer says the high res are availabile via a different codec – MJPEG vs YUY2 (8000×6000 @ 5fps MJPEG / 4000×3000 @ 12fps MJPEG
3840×2160 @ 30fps MJPEG) could this be the main issue?
Any pointers greatly appreciated …
Thanks
>> imaqhwinfo(‘macvideo’,1)
ans =
struct with fields:
DefaultFormat: ‘YCbCr422_1920x1080’
DeviceFileSupported: 0
DeviceName: ’48MP USB Camera’
DeviceID: 1
VideoInputConstructor: ‘videoinput(‘macvideo’, 1)’
VideoDeviceConstructor: ‘imaq.VideoDevice(‘macvideo’, 1)’
SupportedFormats: {‘YCbCr422_1280x720’ ‘YCbCr422_1920x1080’ ‘YCbCr422_192x144’ ‘YCbCr422_320x240’ ‘YCbCr422_352x288’ ‘YCbCr422_3840x2160’ ‘YCbCr422_480x360’ ‘YCbCr422_960x540’}
>> macvideo, usb camera, mjpeg, resolution MATLAB Answers — New Questions
R2025a: Simulink scope does not show full data resolution when zooming in during simulation
Hi all,
I use Simulink to run Simulations over long time-ranges (up to 1 year). Because the simulation run for up to 18 hours I use simulink scopes to monitor signals while the simulation is still running (e.g. to evaluate if newly programmed logics work as expected).
I realised that in R2025a the signals are no longer shown in full data resolution when zooming in during the simulation. Before I used R2023b and there the data was shown in full resolution.
Following example shows the difference between R2023b (expected behaviour) and R2025a:
R2023b:
R2025a:
Both images show the same time-range in the same scope of the same model during simulation.
In the scope settings under logging both "Limit dat points to last" and "Decimation" are disabled.
After the simulation is finished the signals in R2025a are also shown in full data resolution. The difference between the versions only appears during simulation.
Are there any possibilities to get the same behaviour during the simulation as in R2023b? As our simulations run for multiple hours it is important to have the possibility to evaluate the signals even before the simulations are finished.Hi all,
I use Simulink to run Simulations over long time-ranges (up to 1 year). Because the simulation run for up to 18 hours I use simulink scopes to monitor signals while the simulation is still running (e.g. to evaluate if newly programmed logics work as expected).
I realised that in R2025a the signals are no longer shown in full data resolution when zooming in during the simulation. Before I used R2023b and there the data was shown in full resolution.
Following example shows the difference between R2023b (expected behaviour) and R2025a:
R2023b:
R2025a:
Both images show the same time-range in the same scope of the same model during simulation.
In the scope settings under logging both "Limit dat points to last" and "Decimation" are disabled.
After the simulation is finished the signals in R2025a are also shown in full data resolution. The difference between the versions only appears during simulation.
Are there any possibilities to get the same behaviour during the simulation as in R2023b? As our simulations run for multiple hours it is important to have the possibility to evaluate the signals even before the simulations are finished. Hi all,
I use Simulink to run Simulations over long time-ranges (up to 1 year). Because the simulation run for up to 18 hours I use simulink scopes to monitor signals while the simulation is still running (e.g. to evaluate if newly programmed logics work as expected).
I realised that in R2025a the signals are no longer shown in full data resolution when zooming in during the simulation. Before I used R2023b and there the data was shown in full resolution.
Following example shows the difference between R2023b (expected behaviour) and R2025a:
R2023b:
R2025a:
Both images show the same time-range in the same scope of the same model during simulation.
In the scope settings under logging both "Limit dat points to last" and "Decimation" are disabled.
After the simulation is finished the signals in R2025a are also shown in full data resolution. The difference between the versions only appears during simulation.
Are there any possibilities to get the same behaviour during the simulation as in R2023b? As our simulations run for multiple hours it is important to have the possibility to evaluate the signals even before the simulations are finished. scope MATLAB Answers — New Questions
Warning when executing Matlab executable application built with Matlab 2022b
I am building a Matlab executable with Matlab 2022b (including Matlab Compiler). The build is ok and the application works, but when I run it from Windows command prompt or powershell, I get this warning:
Warning: Executing startup failed in matlabrc.
This indicates a potentially serious problem in your MATLAB setup, which should be resolved as soon as possible. Error detected was:
MATLAB:class:InvalidSuperClass
The specified superclass ‘Simulink.IntEnumType’ contains a parse error, cannot be found on MATLAB’s search path, or is shadowed by another file with the same name.
This also happen from another pc with another installation of Matlab, so it does not seem to be a specific problem of my pc. How can I get rid of the warning?I am building a Matlab executable with Matlab 2022b (including Matlab Compiler). The build is ok and the application works, but when I run it from Windows command prompt or powershell, I get this warning:
Warning: Executing startup failed in matlabrc.
This indicates a potentially serious problem in your MATLAB setup, which should be resolved as soon as possible. Error detected was:
MATLAB:class:InvalidSuperClass
The specified superclass ‘Simulink.IntEnumType’ contains a parse error, cannot be found on MATLAB’s search path, or is shadowed by another file with the same name.
This also happen from another pc with another installation of Matlab, so it does not seem to be a specific problem of my pc. How can I get rid of the warning? I am building a Matlab executable with Matlab 2022b (including Matlab Compiler). The build is ok and the application works, but when I run it from Windows command prompt or powershell, I get this warning:
Warning: Executing startup failed in matlabrc.
This indicates a potentially serious problem in your MATLAB setup, which should be resolved as soon as possible. Error detected was:
MATLAB:class:InvalidSuperClass
The specified superclass ‘Simulink.IntEnumType’ contains a parse error, cannot be found on MATLAB’s search path, or is shadowed by another file with the same name.
This also happen from another pc with another installation of Matlab, so it does not seem to be a specific problem of my pc. How can I get rid of the warning? matlab compiler MATLAB Answers — New Questions
Update Inport/outport and signal names faster
I am trying to update a lot of port and signal names. We usually use a prefix like "LvrA_" before all signal names to make code integration easier later. However if we ever need to change it to something like "Lvr1_" the fastest way I’ve found is to click in each box of the Model Data Editor for 100+ ports and signals. Is there a better way to do a find replace, export to a file that allows doing find replace and import or something else similar? Maybe I’ve been using poor keywords but I’ve been searching and can’t seem to find anything.I am trying to update a lot of port and signal names. We usually use a prefix like "LvrA_" before all signal names to make code integration easier later. However if we ever need to change it to something like "Lvr1_" the fastest way I’ve found is to click in each box of the Model Data Editor for 100+ ports and signals. Is there a better way to do a find replace, export to a file that allows doing find replace and import or something else similar? Maybe I’ve been using poor keywords but I’ve been searching and can’t seem to find anything. I am trying to update a lot of port and signal names. We usually use a prefix like "LvrA_" before all signal names to make code integration easier later. However if we ever need to change it to something like "Lvr1_" the fastest way I’ve found is to click in each box of the Model Data Editor for 100+ ports and signals. Is there a better way to do a find replace, export to a file that allows doing find replace and import or something else similar? Maybe I’ve been using poor keywords but I’ve been searching and can’t seem to find anything. inport, naming, signal MATLAB Answers — New Questions
Why is the definition of Weibull PDF not consistent across different MATLAB online documentation web pages?
I see that there is an inconsistency in the expressions of the Weibull distribution functions across two different MATLAB documentation pages.
1) Weibull Distribution (Statistics Toolbox): Here the expression is given as:
y = (b/a) * (x/a)^(b−1) * e^−((x/a)^b)
2) Weibull Distribution (Curve Fitting Toolbox): But here the expression is given as:
y = a * b * x^(b−1) * e^−((ax)^b)I see that there is an inconsistency in the expressions of the Weibull distribution functions across two different MATLAB documentation pages.
1) Weibull Distribution (Statistics Toolbox): Here the expression is given as:
y = (b/a) * (x/a)^(b−1) * e^−((x/a)^b)
2) Weibull Distribution (Curve Fitting Toolbox): But here the expression is given as:
y = a * b * x^(b−1) * e^−((ax)^b) I see that there is an inconsistency in the expressions of the Weibull distribution functions across two different MATLAB documentation pages.
1) Weibull Distribution (Statistics Toolbox): Here the expression is given as:
y = (b/a) * (x/a)^(b−1) * e^−((x/a)^b)
2) Weibull Distribution (Curve Fitting Toolbox): But here the expression is given as:
y = a * b * x^(b−1) * e^−((ax)^b) weibull, distribution MATLAB Answers — New Questions
Why does converting my model into a masked subsystem result in an error indicating a mismatch between the inferred signal size and the size determined by back propagation in MATLAB R2022a?
When I transform my model into a masked subsystem and run the Simulink model, I encounter the following error message:
Error:Inferred size (‘[<signal_size>]’) for data ‘y’ does not match back propagated size (‘scalar’) from Simulink.
Why does converting my model into a masked subsystem result in an error indicating a mismatch between the inferred signal size and the size determined by back propagation in MATLAB R2022a?When I transform my model into a masked subsystem and run the Simulink model, I encounter the following error message:
Error:Inferred size (‘[<signal_size>]’) for data ‘y’ does not match back propagated size (‘scalar’) from Simulink.
Why does converting my model into a masked subsystem result in an error indicating a mismatch between the inferred signal size and the size determined by back propagation in MATLAB R2022a? When I transform my model into a masked subsystem and run the Simulink model, I encounter the following error message:
Error:Inferred size (‘[<signal_size>]’) for data ‘y’ does not match back propagated size (‘scalar’) from Simulink.
Why does converting my model into a masked subsystem result in an error indicating a mismatch between the inferred signal size and the size determined by back propagation in MATLAB R2022a? inferred, signal, size, back, propagation, masked, subsystem MATLAB Answers — New Questions
Access class methods in one line only when you use brackets after class name.
Hello, I’m hoping someone can explain why you can access a class method in a single statement only when you use brackets after the class name.
For example, I have a class called Data, with method stats. Why does Data.stats raise and error, but Data().stats does not raise an error.
The brackets are not required to instantiate the class, i.e. D = Data is the same as D = Data().
Thanks,
Dale.Hello, I’m hoping someone can explain why you can access a class method in a single statement only when you use brackets after the class name.
For example, I have a class called Data, with method stats. Why does Data.stats raise and error, but Data().stats does not raise an error.
The brackets are not required to instantiate the class, i.e. D = Data is the same as D = Data().
Thanks,
Dale. Hello, I’m hoping someone can explain why you can access a class method in a single statement only when you use brackets after the class name.
For example, I have a class called Data, with method stats. Why does Data.stats raise and error, but Data().stats does not raise an error.
The brackets are not required to instantiate the class, i.e. D = Data is the same as D = Data().
Thanks,
Dale. object oriented, method calls MATLAB Answers — New Questions
How can I resolve the “Out of Memory” error without making any changes to the Simulink model?
I’m working with an large Simulink model and encounter an "Out of Memory" error during simulation. I prefer not to alter the model itself. How can I resolve the "Out of Memory" error without making any changes to the Simulink model?I’m working with an large Simulink model and encounter an "Out of Memory" error during simulation. I prefer not to alter the model itself. How can I resolve the "Out of Memory" error without making any changes to the Simulink model? I’m working with an large Simulink model and encounter an "Out of Memory" error during simulation. I prefer not to alter the model itself. How can I resolve the "Out of Memory" error without making any changes to the Simulink model? out, of, memory, operating, point, without, no, change MATLAB Answers — New Questions
How to find the switching losses (reverse recovery losses) of the antiparallel diodes that are in a power converter?
Hello,
My objective is to estimate both conduction and switching losses of semiconductor devices that are used in a DAB converter operation. I have built a simulator using the blocks which can be found in the Simscape library blocks. The semiconductors have been modeled using
1) IGBT (ideal switching) block – IGBT (Ideal, Switching) – Ideal insulated-gate bipolar transistor for switching applications – MATLAB
2) Diode block – Diode – Piecewise linear, exponential, or tabulated diode – MATLAB.
After building the simulator, I ran it for sometime and obtained the simscape results data log for further analysis. And as mentioned in ee_getPowerLossSummary – Calculate dissipated power losses and switching losses – MATLAB, I used that method to estimate both switching and conduction losses using log data. I suppose that the "power" output of the function corresponds to conduction losses. Please advice me otherwise. If the "power" provides the total losses. The provided link of the ee_getPowerLossSummary, it says that the function is capable of estimating both conduction and switching losses for the above devices. Also, highlights that the reverse recovery loss can also be obtained.
However, when I run the simulation and run the function ee_GetPowerLossSummary afterwards, It only provides the conduction losses of the diode. Always, the diode losses are given as zero. It provides the conduction and switching losses for the IGBT. I have modeled the diode for reverse recovery operation by adding values from the datasheet. I was wondering whether there are any additional options to configure to get this to work. Also, I can see that the switching losses of the IGBTs fall drastically when a deadtime is used between High and Low switches in a same leg. When deadtime is not used, a signficant amount of switching losses are present. These observations have been made using the aforementioned ee_getPowerLossSummary function and as well as post processing the instantaneuos power waveforms obtained through power sensors. I don’t understand this since switching losses apply even when the deadtime is used since it only happens due to the IGBT’s own voltage and current. Not by the temporary shootthrough that happens if deadtime is not used.
Any suggestion, comment or advice regarding this process is highly appreciated. Thank you.Hello,
My objective is to estimate both conduction and switching losses of semiconductor devices that are used in a DAB converter operation. I have built a simulator using the blocks which can be found in the Simscape library blocks. The semiconductors have been modeled using
1) IGBT (ideal switching) block – IGBT (Ideal, Switching) – Ideal insulated-gate bipolar transistor for switching applications – MATLAB
2) Diode block – Diode – Piecewise linear, exponential, or tabulated diode – MATLAB.
After building the simulator, I ran it for sometime and obtained the simscape results data log for further analysis. And as mentioned in ee_getPowerLossSummary – Calculate dissipated power losses and switching losses – MATLAB, I used that method to estimate both switching and conduction losses using log data. I suppose that the "power" output of the function corresponds to conduction losses. Please advice me otherwise. If the "power" provides the total losses. The provided link of the ee_getPowerLossSummary, it says that the function is capable of estimating both conduction and switching losses for the above devices. Also, highlights that the reverse recovery loss can also be obtained.
However, when I run the simulation and run the function ee_GetPowerLossSummary afterwards, It only provides the conduction losses of the diode. Always, the diode losses are given as zero. It provides the conduction and switching losses for the IGBT. I have modeled the diode for reverse recovery operation by adding values from the datasheet. I was wondering whether there are any additional options to configure to get this to work. Also, I can see that the switching losses of the IGBTs fall drastically when a deadtime is used between High and Low switches in a same leg. When deadtime is not used, a signficant amount of switching losses are present. These observations have been made using the aforementioned ee_getPowerLossSummary function and as well as post processing the instantaneuos power waveforms obtained through power sensors. I don’t understand this since switching losses apply even when the deadtime is used since it only happens due to the IGBT’s own voltage and current. Not by the temporary shootthrough that happens if deadtime is not used.
Any suggestion, comment or advice regarding this process is highly appreciated. Thank you. Hello,
My objective is to estimate both conduction and switching losses of semiconductor devices that are used in a DAB converter operation. I have built a simulator using the blocks which can be found in the Simscape library blocks. The semiconductors have been modeled using
1) IGBT (ideal switching) block – IGBT (Ideal, Switching) – Ideal insulated-gate bipolar transistor for switching applications – MATLAB
2) Diode block – Diode – Piecewise linear, exponential, or tabulated diode – MATLAB.
After building the simulator, I ran it for sometime and obtained the simscape results data log for further analysis. And as mentioned in ee_getPowerLossSummary – Calculate dissipated power losses and switching losses – MATLAB, I used that method to estimate both switching and conduction losses using log data. I suppose that the "power" output of the function corresponds to conduction losses. Please advice me otherwise. If the "power" provides the total losses. The provided link of the ee_getPowerLossSummary, it says that the function is capable of estimating both conduction and switching losses for the above devices. Also, highlights that the reverse recovery loss can also be obtained.
However, when I run the simulation and run the function ee_GetPowerLossSummary afterwards, It only provides the conduction losses of the diode. Always, the diode losses are given as zero. It provides the conduction and switching losses for the IGBT. I have modeled the diode for reverse recovery operation by adding values from the datasheet. I was wondering whether there are any additional options to configure to get this to work. Also, I can see that the switching losses of the IGBTs fall drastically when a deadtime is used between High and Low switches in a same leg. When deadtime is not used, a signficant amount of switching losses are present. These observations have been made using the aforementioned ee_getPowerLossSummary function and as well as post processing the instantaneuos power waveforms obtained through power sensors. I don’t understand this since switching losses apply even when the deadtime is used since it only happens due to the IGBT’s own voltage and current. Not by the temporary shootthrough that happens if deadtime is not used.
Any suggestion, comment or advice regarding this process is highly appreciated. Thank you. simulink, dab, loss, igbt, diode, switching losses, reverse recovery losses MATLAB Answers — New Questions
NXP S32k1xx Toolbox installation
Hi everyone,
I’m trying to install nxp toolbox but getting given below error kindly help me out.
Dot indexing is not supported for variables of this type.
Error in NXP_Support_Package_S32K1xx>ConvertToolbox_Callback (line 143)
user_selection = get(handles.mbdt_version,’Value’);
^^^^^^^^^^^^^^^^^^^^
Error in gui_mainfcn (line 95)
feval(varargin{:});
^^^^^^^^^^^^^^^^^^
Error in NXP_Support_Package_S32K1xx (line 34)
gui_mainfcn(gui_State, varargin{:});
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error in matlab.graphics.internal.figfile.FigFile/read>@(hObject,eventdata)NXP_Support_Package_S32K1xx(‘ConvertToolbox_Callback’,hObject,eventdata,guidata(hObject))
Error using matlab.ui.internal.controller.uicontrol.UIControlController/triggerActionEvent (line 76)
Error while evaluating UIControl Callback.
regards,
Durgaprasad BHi everyone,
I’m trying to install nxp toolbox but getting given below error kindly help me out.
Dot indexing is not supported for variables of this type.
Error in NXP_Support_Package_S32K1xx>ConvertToolbox_Callback (line 143)
user_selection = get(handles.mbdt_version,’Value’);
^^^^^^^^^^^^^^^^^^^^
Error in gui_mainfcn (line 95)
feval(varargin{:});
^^^^^^^^^^^^^^^^^^
Error in NXP_Support_Package_S32K1xx (line 34)
gui_mainfcn(gui_State, varargin{:});
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error in matlab.graphics.internal.figfile.FigFile/read>@(hObject,eventdata)NXP_Support_Package_S32K1xx(‘ConvertToolbox_Callback’,hObject,eventdata,guidata(hObject))
Error using matlab.ui.internal.controller.uicontrol.UIControlController/triggerActionEvent (line 76)
Error while evaluating UIControl Callback.
regards,
Durgaprasad B Hi everyone,
I’m trying to install nxp toolbox but getting given below error kindly help me out.
Dot indexing is not supported for variables of this type.
Error in NXP_Support_Package_S32K1xx>ConvertToolbox_Callback (line 143)
user_selection = get(handles.mbdt_version,’Value’);
^^^^^^^^^^^^^^^^^^^^
Error in gui_mainfcn (line 95)
feval(varargin{:});
^^^^^^^^^^^^^^^^^^
Error in NXP_Support_Package_S32K1xx (line 34)
gui_mainfcn(gui_State, varargin{:});
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error in matlab.graphics.internal.figfile.FigFile/read>@(hObject,eventdata)NXP_Support_Package_S32K1xx(‘ConvertToolbox_Callback’,hObject,eventdata,guidata(hObject))
Error using matlab.ui.internal.controller.uicontrol.UIControlController/triggerActionEvent (line 76)
Error while evaluating UIControl Callback.
regards,
Durgaprasad B nxp toolbox MATLAB Answers — New Questions
How can I edit the properties for multiple requirements in the Requirements Editor in MATLAB R2024b?
Consider the requirement set file shown in the figure below, which is open in MATLAB R2024b. When I select multiple requirements, the "Properties" pane is greyed out and I cannot edit the properties for multiple requirements. How can I get around this?Consider the requirement set file shown in the figure below, which is open in MATLAB R2024b. When I select multiple requirements, the "Properties" pane is greyed out and I cannot edit the properties for multiple requirements. How can I get around this? Consider the requirement set file shown in the figure below, which is open in MATLAB R2024b. When I select multiple requirements, the "Properties" pane is greyed out and I cannot edit the properties for multiple requirements. How can I get around this? simulink, requirements, requirements-toolbox MATLAB Answers — New Questions
Help with Plotting the Envelope of a Scatter Plot in MATLAB
Hello everyone,
I’m trying to plot the envelope of a scatter plot in MATLAB. However, when I use the envelope function, it returns the same plot without highlighting the upper or lower bounds.
This plot was created using a scatter plot, and when I attempt to filter it to retain only the extremum values, I end up with just a single slice of the data.
Has anyone encountered a similar issue or knows how I could extract and plot the envelope correctly (in red), as shown in the reference image?
Thanks in advance!Hello everyone,
I’m trying to plot the envelope of a scatter plot in MATLAB. However, when I use the envelope function, it returns the same plot without highlighting the upper or lower bounds.
This plot was created using a scatter plot, and when I attempt to filter it to retain only the extremum values, I end up with just a single slice of the data.
Has anyone encountered a similar issue or knows how I could extract and plot the envelope correctly (in red), as shown in the reference image?
Thanks in advance! Hello everyone,
I’m trying to plot the envelope of a scatter plot in MATLAB. However, when I use the envelope function, it returns the same plot without highlighting the upper or lower bounds.
This plot was created using a scatter plot, and when I attempt to filter it to retain only the extremum values, I end up with just a single slice of the data.
Has anyone encountered a similar issue or knows how I could extract and plot the envelope correctly (in red), as shown in the reference image?
Thanks in advance! scatter, enveloppe, filtering MATLAB Answers — New Questions
I AM TRYING TO CONTROL SYNCHRONOUS RELUCTANCE MOTOR USING FOC. (Rs) = 8 Ω, (Ld) = 1.2 H (Lq) = 0.1 H P= 2, (J) = 0.125 kg·m² , (B) = 0.009 IF THE SIMULATION DIAGRAM IS OK
Post Content Post Content synchronous reluctance motor using foc MATLAB Answers — New Questions
Error when applying coder to WLAN Toolbox example code
An error occurs when using Matlab coder with hWLANPacketDetector.m used in SDRBeaconReceiverExample.mlx.An error occurs when using Matlab coder with hWLANPacketDetector.m used in SDRBeaconReceiverExample.mlx. An error occurs when using Matlab coder with hWLANPacketDetector.m used in SDRBeaconReceiverExample.mlx. wlan coder MATLAB Answers — New Questions
Please guide me, I can’t find the F280049 Flash file, on TMS320F280049 when using Uniflash it will only work once, after reset it won’t work.
Please guide me, I can’t find the F280049 Flash file, on TMS320F280049 when using Uniflash it will only work once, after reset it won’t work. After reset, it might be from the MCU boosting from RAM?Please guide me, I can’t find the F280049 Flash file, on TMS320F280049 when using Uniflash it will only work once, after reset it won’t work. After reset, it might be from the MCU boosting from RAM? Please guide me, I can’t find the F280049 Flash file, on TMS320F280049 when using Uniflash it will only work once, after reset it won’t work. After reset, it might be from the MCU boosting from RAM? c2000, simulink MATLAB Answers — New Questions
Expansion of expressions involving Einstein summation convention with Levi-Civita tensors
Dear all
I am evaluating expressions of the type
where all the subindices , and the dot on the variable , , symbolizes the time derivative.
I’d be interested in being able to ask MatLab for the fully expanded , , and , so I can then numerically evaluate those terms. Ideally, it would be a plus if it also gave me the monstrous explicit expressions in LaTeX and/or could extrapolate the expanded expression to C++.
Do you have any ideas on how I could do this?Dear all
I am evaluating expressions of the type
where all the subindices , and the dot on the variable , , symbolizes the time derivative.
I’d be interested in being able to ask MatLab for the fully expanded , , and , so I can then numerically evaluate those terms. Ideally, it would be a plus if it also gave me the monstrous explicit expressions in LaTeX and/or could extrapolate the expanded expression to C++.
Do you have any ideas on how I could do this? Dear all
I am evaluating expressions of the type
where all the subindices , and the dot on the variable , , symbolizes the time derivative.
I’d be interested in being able to ask MatLab for the fully expanded , , and , so I can then numerically evaluate those terms. Ideally, it would be a plus if it also gave me the monstrous explicit expressions in LaTeX and/or could extrapolate the expanded expression to C++.
Do you have any ideas on how I could do this? symbolic to numeric expressions, einstein summation convention MATLAB Answers — New Questions
Resonance in moonpool type structures
I have the following code for my problem where i apply the match eigen function technique to find the unknown coefficients and then plotting one result wave motion inside a moonpool structure. However the expected plot for me should be decreasing after the resonance peak. But in my code it is decrease but then again blows up. I did not find any source of error. The analytical expressions which i used for my problem is write in pdf file at the end. Here is my code . I just want to figure out my source of error to fix it but i couldn’t. So I need help in acheiving my desired results. I also attached the refrence plot.
clear all;
close all;
clc;
tic;
% Parameters from your setup
N = 5; % Number of evanescent modes
M = 3; % Number of azimuthal modes
RE = 1.0; % Outer radius (m)
ratio = 2.0; % Ratio R_E / R_I
RI = RE / ratio; % Inner radius (m)
h = 4.0 * RE; % Water depth (m)
b = 2.0; % Distance from cylinder bottom to seabed (m)
d = h – b; % Interface depth (m)
g = 9.81; % Gravity (m/s^2)
l = 0; % Azimuthal order
% I_given_wavenumber = 1;
X_kRE = linspace(0.01, 4, 200);
% Initialize eta0 array before loop
eta0 = zeros(size(X_kRE)); % Preallocate
for idx = 1:length(X_kRE)
% if I_given_wavenumber == 1
wk = X_kRE(idx) / RE; % dimensional wavenumber
omega = sqrt(g * wk * tanh(wk * h)); % dispersion relation
fun_alpha = @(x) omega^2 + g*x.*tan(x*h); %dispersion equation for evanescent modes
for n = 1:N
if n == 1
k(n) = -1i * wk;
else
x0_left = (2*n – 3) * pi / (2*h);
x0_right = (2*n – 1) * pi / (2*h);
guess = (x0_left + x0_right)/2;
% Use lsqnonlin for better convergence
k(n) = lsqnonlin(fun_alpha, guess, x0_left, x0_right);
end
end
% % find evanescent modes k1…k_{N-1} stored in k_all(2)…k_all(N)
% for n = 2 : N
% m = n – 1; % mode index for evanescent
% a = ((2*m-1)*pi)/(2*h) + eps;
% b = (m*pi)/h – eps;
% % at a: tan→ -∞ so f(a)<0; at b: tan→0 so f(b)=+omega^2>0
% k_all(n) = fzero(@(k) g*k.*tan(k*h) + omega^2, [a, b]);
% end
% % % end
%% finding the root lemda_m =m*pi/b%%%%%%
for j=1:M
m(j)=(pi*(j-1))/b;
end
% %%%%%%%%%%%%%%%%%%%%% Define matrix A %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
A = zeros(M,N);
A(1,1) = (cosh(wk*h)*sinh(wk*b))/(wk*b*(2*wk*h+sinh(2*wk*h)))*(besselh(l, wk*RE)) /(dbesselh(l, wk*RE)); % Set A_00
for j = 2:N
A(1,j) =(cos(k(j)*h)*sin(k(j)*b) )/ (k(j)*b*(2*k(j)*h + sin(2*k(j)*h)))*( besselk(l, k(j)*RE) )…
/(dbesselk(l, k(j)*RE)); % Set A_0n
end
for i = 2:M
A(i,1) =(2 * cosh(wk*h) * (-1)^(i-1) * wk*sinh(wk*b)) / (b * (2*wk*h + sinh(2*wk*h))*(wk^2 + m(i)^2))…
* (besselh(l, wk*RE))/ (dbesselh(l, wk*RE)); % Set A_m0
end
for i = 2:M
for j = 2:N
A(i,j) = (2*cos(k(j)*h)*(-1)^(i-1) *k(j)* sin(k(j)*b))/ (b * (2*k(j)*h + sin(2*k(j)*h))*(k(j)^2-m(i)^2))…
*(besselk(l, k(j)*RE)) / (dbesselk(l, k(j)*RE));% Set A_mn
end
end
%%%%%%%%%%%%%%%%%%%%%%%% DefineMatrix B %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
B=zeros(N,M);
B(1,1) = (4*sinh(wk*b)) / (RE * wk*log(RE/RI) *cosh(wk*h)); %set B_00
%%%%%%%%%%%B_0m%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
for j = 2:M
Rml_prime_RE = m(j)*(besselk(l, m(j)*RI) * dbesseli(l, m(j)*RE) …
– besseli(l, m(j)*RI) * dbesselk(l, m(j)*RE))…
/(besselk(l, m(j)*RI) * besseli(l, m(j)*RE) – besselk(l, m(j)*RE) * besseli(l, m(j)*RI));
B(1,j) = Rml_prime_RE * (4 * wk * (-1)^(j-1) * sinh(wk*b)) / (cosh(wk*h) * (wk^2 + m(j)^2));
end
%%%%%%%%%%%B_n0%%%%%%%%%%%%%%%%%%%%%%%%%%%
for i=2:N
B(i,1)=(4*sin(k(i)*b))/(RE*k(i)*log(RE/RI)*cos(k(i)*h));% Set B_n0
end
%%%%%%%%%%%%%%%%%%%%%%%%%%B_nm%%%%%%%%%%%%%%%%%%%%%%%%%%%%
for i=2:N
for j=2:M
Rml_prime_RE = m(j)*(besselk(l, m(j)*RI) * dbesseli(l, m(j)*RE) …
– besseli(l, m(j)*RI) * dbesselk(l, m(j)*RE))…
/(besselk(l, m(j)*RI) * besseli(l, m(j)*RE) – besselk(l, m(j)*RE) * besseli(l, m(j)*RI));
B(i,j) = Rml_prime_RE * (4 * k(i) * (-1)^(j-1) * sin(k(i)*b)) / (cos(k(i)*h) * (k(i)^2 – m(j)^2));
end
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Define Matrix C %%%%%%%%%%%%%%%%%%%%%%%%
C = zeros(N,M);
C(1,1) = -4 * sinh(wk*b) / (RE * wk*log(RE/RI) * cosh(wk*h));
% %%%%% DEfine C0m%%%%%%
for j = 2:M
Rml_prime_star_RE = m(j)*(besseli(l, m(j)*RE) * dbesselk(l, m(j)*RE) …
– besselk(l, m(j)*RE) * dbesseli(l, m(j)*RE))…
/(besselk(l, m(j)*RI) * besseli(l, m(j)*RE) – besselk(l, m(j)*RE) * besseli(l, m(j)*RI));
C(1,j) = Rml_prime_star_RE * (4 * wk * (-1)^(j-1) * sinh(wk*b)) / (cosh(wk*h) * (wk^2 + m(j)^2));
end
% %%%%%%% Define Cn0%%%%%%
for i = 2:N
C(i,1) = -4 * sin(k(i)*b) / (RE *k(i)* log(RE/RI) * cos(k(i)*h));
end
% % %%%%%% Define Cnm%%%%%%
for i = 2:N
for j =2:M
Rml_prime_star_RE = m(j)*(besseli(l, m(j)*RE) * dbesselk(l, m(j)*RE) …
– besselk(l, m(j)*RE) * dbesseli(l, m(j)*RE))…
/(besselk(l, m(j)*RI) * besseli(l, m(j)*RE) – besselk(l, m(j)*RE) * besseli(l, m(j)*RI));
C(i,j) = Rml_prime_star_RE * (4 * k(i) * (-1)^(j-1) * sin(k(i)*b)) / (cos(k(i)*h) * (k(i)^2 – m(j)^2));
end
end
%%%%%%% write Matrix D %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
D = zeros(M,N);
%%% write D00 %%%%%%
D(1,1) = (cosh(wk*h) * sinh(wk*b)) / (wk*b * (2*wk*h + sinh(2*wk*h))) * (besselj(l, wk*RI))/ (dbesselj(l, wk*RI));
%%%%% write D0n %%%%%%%%%%
for j =2:N
D(1,j) = (cos(k(j)*h) * sin(k(j)*b)) / (k(j)*b * (2*k(j)*h + sin(2*k(j)*h))) * (besseli(l, k(j)*RI) )/ (dbesseli(l, k(j)*RI));
end
%%%%%% write Dm0 %%%%%%%%%
for i = 2:M
D(i,1) = (2 * cosh(wk*h) * (-1)^(i-1) * wk * sinh(wk*b)) /(b * (2*wk*h + sinh(2*wk*h)) * (wk^2 + m(i)^2))…
*(besselj(l, wk*RI) )/(dbesselj(l, wk*RI));
end
%%%%% Define Dmn%%%%%%%%
for i = 2:M
for j = 2:N
D(i,j) = (2 * cos(k(j)*h) * (-1)^(i-1) * k(j) * sin(k(j)*b)) /(b * (2*k(j)*h + sin(2*k(j)*h)) * (k(j)^2 – m(i)^2))…
*(besseli(l, k(j)*RI)) / (dbesseli(l, k(j)*RI));
end
end
%%%%%%%%%%%%%%%%%%%%%%%%%% Define Matrix E %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
E = zeros(N, M); % Preallocate the matrix E
%%%%% Define E00%%%%%%%%%%%%
E(1,1) = (4 * sinh(wk*b)) / (RI *wk* log(RE/RI) * cosh(wk*h));
%%%% Define Eom %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
for j = 2:M
Rml_prime_RI = m(j)*(besselk(l, m(j)*RI) * dbesseli(l, m(j)*RI) …
– besseli(l, m(j)*RI) * dbesselk(l, m(j)*RI))…
/ (besselk(l, m(j)*RI) * besseli(l, m(j)*RE) – besselk(l, m(j)*RE) * besseli(l, m(j)*RI));
E(1,j) = Rml_prime_RI * (4 * wk * (-1)^(j-1) * sinh(wk*b)) / (cosh(wk*h) * (wk^2 + m(j)^2));
%
end
%%%%%% Define Eno%%%%%%%%%%%%%%
for i = 2:N
E(i,1) = (4 * sin(k(i)*b)) / (RI *k(i)* log(RE/RI) * cos(k(i)*h));
end
for i = 2:N
for j = 2:M
Rml_prime_RI = m(j)*(besselk(l, m(j)*RI) * dbesseli(l, m(j)*RI) …
– besseli(l, m(j)*RI) * dbesselk(l, m(j)*RI))…
/ (besselk(l, m(j)*RI) * besseli(l, m(j)*RE) – besselk(l, m(j)*RE) * besseli(l, m(j)*RI));
E(i,j) = Rml_prime_RI * (4 * k(i) * (-1)^(j-1) * sin(k(i)*b)) / (cos(k(i)*h) * (k(i)^2 – m(j)^2));
end
end
%%%%%%%%%%%%%%%%%%%%%%%% Now write matrix F %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
F = zeros(N,M);
%%%%%%%% Define F00 %%%%%%%%%%
F(1,1) = (-4 * sinh(wk*b)) / (RI * wk*log(RE/RI) * cosh(wk*h));
% %%%%%% Define F0m%%%%
for j = 2:M
Rml_star_prime_RI = m(j)*(besseli(l, m(j)*RE) * dbesselk(l, m(j)*RI) …
– besselk(l, m(j)*RE) * dbesseli(l, m(j)*RI))/((besselk(l, m(j)*RI) …
* besseli(l, m(j)*RE) – besselk(l, m(j)*RE) * besseli(l, m(j)*RI)));
F(1,j) = Rml_star_prime_RI * (4 * wk * (-1)^(j-1) * sinh(wk*b)) / (cosh(wk*h) * (wk^2 + m(j)^2));
end
%%%%% Defin Fn0%%%%%%
for i = 2:N
F(i,1) = (-4 * sin(k(i)*b)) / (RI *k(i)* log(RE/RI) * cos(k(i)*h));
end
%%%%%%% Define Fnm %%%%%%%
for i = 2:N
for j = 2:M
Rml_star_prime_RI = m(j)*(besseli(l, m(j)*RE) * dbesselk(l, m(j)*RI) …
– besselk(l, m(j)*RE) * dbesseli(l, m(j)*RI))/((besselk(l, m(j)*RI) …
* besseli(l, m(j)*RE) – besselk(l, m(j)*RE) * besseli(l, m(j)*RI)));
F(i,j) = Rml_star_prime_RI * (4 * k(i)* (-1)^(j-1) * sin(k(i)*b)) / (cos(k(i)*h) * (k(i)^2 – m(j)^2));
end
end
% % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% % Define right-hand side vector G
G = zeros(2*M+2*N, 1); % Total length = M + N+ M+ N = 2M+2N
%
% Block 1: G (size M = 4)
for i = 1:M
if i == 1
G(i, 1) = (sinh(wk*b))/((b*wk)*cosh(wk*h))*besselj(l, wk*RE) ; % Z_0^l
else
G(i, 1) = (2 *wk*(-1)^(i-1)*sinh(wk*b))/(b *(wk^2 +m(i)^2))*besselj(l, wk*RE); %Z_m^l
end
end
%
% Block 2: Y (size N = 3)
for j = 1:N
if j == 1
G(j + M, 1) = -dbesselj(l, wk*RE) * (2*wk*h + sinh(2*wk*h)) /(cosh(wk*h)^2); % Y_0^l
else
G(j + M, 1) = 0; % Y_n^l
end
end
% Block 3: X (size M = 4)
for i = 1:M
G(i + M + N, 1) = 0; % X_0^l, X_m^l
end
% Block 4: W (size N = 3)
for j = 1:N
G(j + M + N + M, 1) = 0; % W_0^l, W_n^l
end
% Identity matrices
I_M = eye(M);
I_N = eye(N);
% Zero matrices
ZMM = zeros(M, M);
ZMN = zeros(M, N);
ZNM = zeros(N, M);
ZNN = zeros(N, N);
% Construct the full block matrix H
H = [ I_M, -A, ZMM, ZMN; % Block row 1
-B, I_N, -C, ZNN; % Block row 2
ZMM, ZMN, I_M, -D; % Block row 3
-E, ZNN, -F, I_N]; % Block row 4
% X = H G; % Solve the linear system
X = pinv(H) * G; % Use pseudoinverse for stability
%
b_vec = X(1:M); % Coefficients b^l
a_vec = X(M+1 : M+N); % Coefficients a^l
c_vec = X(M+N+1 : 2*M+N); % Coefficients c^l
d_vec = X(2*M+N+1 : end); % Coefficients d^l
%%%%%%%%% Wave motion%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
term1 = (d_vec(1)*cosh(wk*h)^2) / ((2*wk*h + sinh(2*wk*h)) * dbesselj(l, wk*RI));
sum1 = 0;
for n =2:N
sum1 = sum1 + d_vec(n)*cos(k(n)*h)^2/ ((2*k(n)*h + sin(2*k(n)*h))* dbesseli(l, k(n)*RI));
end
eta0(idx) = abs(term1+sum1);
% % disp(k.’) % Should all be real and positive for n ≥ 2
% %
% %
end
plot(X_kRE, eta0, ‘k’, ‘LineWidth’, 1.5);
xlabel(‘$k_0 R_E$’, ‘Interpreter’, ‘latex’);
ylabel(‘$eta / (iA)$’, ‘Interpreter’, ‘latex’);
title(‘Wave motion amplitude for RE/RI = 4.0’);
grid on;
xlim([0 4]); % Match the reference plot
ylim([0 6]); % Optional: based on expected peak height
elapsedTime = toc;
disp([‘Time consuming = ‘, num2str(elapsedTime), ‘ s’]);
function out = dbesselh(l, z)
if l == 0
out = -besselh(1, 1, z);
else
out = 0.5 * (besselh(l – 1, 1, z) – besselh(l + 1, 1, z));
end
end
function out = dbesseli(l, z)
if l == 0
out = besseli(1, z);
else
out = 0.5 * (besseli(l – 1, z) + besseli(l + 1, z));
end
end
function out = dbesselj(l, z)
if l == 0
out = -besselj(1, z);
else
out = 0.5 * (besselj(l – 1, z) – besselj(l + 1, z));
end
end
function out = dbesselk(l, z)
if l == 0
out = -besselk(1, z);
else
out = -0.5 * (besselk(l – 1, z) + besselk(l + 1, z));
end
endI have the following code for my problem where i apply the match eigen function technique to find the unknown coefficients and then plotting one result wave motion inside a moonpool structure. However the expected plot for me should be decreasing after the resonance peak. But in my code it is decrease but then again blows up. I did not find any source of error. The analytical expressions which i used for my problem is write in pdf file at the end. Here is my code . I just want to figure out my source of error to fix it but i couldn’t. So I need help in acheiving my desired results. I also attached the refrence plot.
clear all;
close all;
clc;
tic;
% Parameters from your setup
N = 5; % Number of evanescent modes
M = 3; % Number of azimuthal modes
RE = 1.0; % Outer radius (m)
ratio = 2.0; % Ratio R_E / R_I
RI = RE / ratio; % Inner radius (m)
h = 4.0 * RE; % Water depth (m)
b = 2.0; % Distance from cylinder bottom to seabed (m)
d = h – b; % Interface depth (m)
g = 9.81; % Gravity (m/s^2)
l = 0; % Azimuthal order
% I_given_wavenumber = 1;
X_kRE = linspace(0.01, 4, 200);
% Initialize eta0 array before loop
eta0 = zeros(size(X_kRE)); % Preallocate
for idx = 1:length(X_kRE)
% if I_given_wavenumber == 1
wk = X_kRE(idx) / RE; % dimensional wavenumber
omega = sqrt(g * wk * tanh(wk * h)); % dispersion relation
fun_alpha = @(x) omega^2 + g*x.*tan(x*h); %dispersion equation for evanescent modes
for n = 1:N
if n == 1
k(n) = -1i * wk;
else
x0_left = (2*n – 3) * pi / (2*h);
x0_right = (2*n – 1) * pi / (2*h);
guess = (x0_left + x0_right)/2;
% Use lsqnonlin for better convergence
k(n) = lsqnonlin(fun_alpha, guess, x0_left, x0_right);
end
end
% % find evanescent modes k1…k_{N-1} stored in k_all(2)…k_all(N)
% for n = 2 : N
% m = n – 1; % mode index for evanescent
% a = ((2*m-1)*pi)/(2*h) + eps;
% b = (m*pi)/h – eps;
% % at a: tan→ -∞ so f(a)<0; at b: tan→0 so f(b)=+omega^2>0
% k_all(n) = fzero(@(k) g*k.*tan(k*h) + omega^2, [a, b]);
% end
% % % end
%% finding the root lemda_m =m*pi/b%%%%%%
for j=1:M
m(j)=(pi*(j-1))/b;
end
% %%%%%%%%%%%%%%%%%%%%% Define matrix A %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
A = zeros(M,N);
A(1,1) = (cosh(wk*h)*sinh(wk*b))/(wk*b*(2*wk*h+sinh(2*wk*h)))*(besselh(l, wk*RE)) /(dbesselh(l, wk*RE)); % Set A_00
for j = 2:N
A(1,j) =(cos(k(j)*h)*sin(k(j)*b) )/ (k(j)*b*(2*k(j)*h + sin(2*k(j)*h)))*( besselk(l, k(j)*RE) )…
/(dbesselk(l, k(j)*RE)); % Set A_0n
end
for i = 2:M
A(i,1) =(2 * cosh(wk*h) * (-1)^(i-1) * wk*sinh(wk*b)) / (b * (2*wk*h + sinh(2*wk*h))*(wk^2 + m(i)^2))…
* (besselh(l, wk*RE))/ (dbesselh(l, wk*RE)); % Set A_m0
end
for i = 2:M
for j = 2:N
A(i,j) = (2*cos(k(j)*h)*(-1)^(i-1) *k(j)* sin(k(j)*b))/ (b * (2*k(j)*h + sin(2*k(j)*h))*(k(j)^2-m(i)^2))…
*(besselk(l, k(j)*RE)) / (dbesselk(l, k(j)*RE));% Set A_mn
end
end
%%%%%%%%%%%%%%%%%%%%%%%% DefineMatrix B %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
B=zeros(N,M);
B(1,1) = (4*sinh(wk*b)) / (RE * wk*log(RE/RI) *cosh(wk*h)); %set B_00
%%%%%%%%%%%B_0m%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
for j = 2:M
Rml_prime_RE = m(j)*(besselk(l, m(j)*RI) * dbesseli(l, m(j)*RE) …
– besseli(l, m(j)*RI) * dbesselk(l, m(j)*RE))…
/(besselk(l, m(j)*RI) * besseli(l, m(j)*RE) – besselk(l, m(j)*RE) * besseli(l, m(j)*RI));
B(1,j) = Rml_prime_RE * (4 * wk * (-1)^(j-1) * sinh(wk*b)) / (cosh(wk*h) * (wk^2 + m(j)^2));
end
%%%%%%%%%%%B_n0%%%%%%%%%%%%%%%%%%%%%%%%%%%
for i=2:N
B(i,1)=(4*sin(k(i)*b))/(RE*k(i)*log(RE/RI)*cos(k(i)*h));% Set B_n0
end
%%%%%%%%%%%%%%%%%%%%%%%%%%B_nm%%%%%%%%%%%%%%%%%%%%%%%%%%%%
for i=2:N
for j=2:M
Rml_prime_RE = m(j)*(besselk(l, m(j)*RI) * dbesseli(l, m(j)*RE) …
– besseli(l, m(j)*RI) * dbesselk(l, m(j)*RE))…
/(besselk(l, m(j)*RI) * besseli(l, m(j)*RE) – besselk(l, m(j)*RE) * besseli(l, m(j)*RI));
B(i,j) = Rml_prime_RE * (4 * k(i) * (-1)^(j-1) * sin(k(i)*b)) / (cos(k(i)*h) * (k(i)^2 – m(j)^2));
end
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Define Matrix C %%%%%%%%%%%%%%%%%%%%%%%%
C = zeros(N,M);
C(1,1) = -4 * sinh(wk*b) / (RE * wk*log(RE/RI) * cosh(wk*h));
% %%%%% DEfine C0m%%%%%%
for j = 2:M
Rml_prime_star_RE = m(j)*(besseli(l, m(j)*RE) * dbesselk(l, m(j)*RE) …
– besselk(l, m(j)*RE) * dbesseli(l, m(j)*RE))…
/(besselk(l, m(j)*RI) * besseli(l, m(j)*RE) – besselk(l, m(j)*RE) * besseli(l, m(j)*RI));
C(1,j) = Rml_prime_star_RE * (4 * wk * (-1)^(j-1) * sinh(wk*b)) / (cosh(wk*h) * (wk^2 + m(j)^2));
end
% %%%%%%% Define Cn0%%%%%%
for i = 2:N
C(i,1) = -4 * sin(k(i)*b) / (RE *k(i)* log(RE/RI) * cos(k(i)*h));
end
% % %%%%%% Define Cnm%%%%%%
for i = 2:N
for j =2:M
Rml_prime_star_RE = m(j)*(besseli(l, m(j)*RE) * dbesselk(l, m(j)*RE) …
– besselk(l, m(j)*RE) * dbesseli(l, m(j)*RE))…
/(besselk(l, m(j)*RI) * besseli(l, m(j)*RE) – besselk(l, m(j)*RE) * besseli(l, m(j)*RI));
C(i,j) = Rml_prime_star_RE * (4 * k(i) * (-1)^(j-1) * sin(k(i)*b)) / (cos(k(i)*h) * (k(i)^2 – m(j)^2));
end
end
%%%%%%% write Matrix D %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
D = zeros(M,N);
%%% write D00 %%%%%%
D(1,1) = (cosh(wk*h) * sinh(wk*b)) / (wk*b * (2*wk*h + sinh(2*wk*h))) * (besselj(l, wk*RI))/ (dbesselj(l, wk*RI));
%%%%% write D0n %%%%%%%%%%
for j =2:N
D(1,j) = (cos(k(j)*h) * sin(k(j)*b)) / (k(j)*b * (2*k(j)*h + sin(2*k(j)*h))) * (besseli(l, k(j)*RI) )/ (dbesseli(l, k(j)*RI));
end
%%%%%% write Dm0 %%%%%%%%%
for i = 2:M
D(i,1) = (2 * cosh(wk*h) * (-1)^(i-1) * wk * sinh(wk*b)) /(b * (2*wk*h + sinh(2*wk*h)) * (wk^2 + m(i)^2))…
*(besselj(l, wk*RI) )/(dbesselj(l, wk*RI));
end
%%%%% Define Dmn%%%%%%%%
for i = 2:M
for j = 2:N
D(i,j) = (2 * cos(k(j)*h) * (-1)^(i-1) * k(j) * sin(k(j)*b)) /(b * (2*k(j)*h + sin(2*k(j)*h)) * (k(j)^2 – m(i)^2))…
*(besseli(l, k(j)*RI)) / (dbesseli(l, k(j)*RI));
end
end
%%%%%%%%%%%%%%%%%%%%%%%%%% Define Matrix E %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
E = zeros(N, M); % Preallocate the matrix E
%%%%% Define E00%%%%%%%%%%%%
E(1,1) = (4 * sinh(wk*b)) / (RI *wk* log(RE/RI) * cosh(wk*h));
%%%% Define Eom %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
for j = 2:M
Rml_prime_RI = m(j)*(besselk(l, m(j)*RI) * dbesseli(l, m(j)*RI) …
– besseli(l, m(j)*RI) * dbesselk(l, m(j)*RI))…
/ (besselk(l, m(j)*RI) * besseli(l, m(j)*RE) – besselk(l, m(j)*RE) * besseli(l, m(j)*RI));
E(1,j) = Rml_prime_RI * (4 * wk * (-1)^(j-1) * sinh(wk*b)) / (cosh(wk*h) * (wk^2 + m(j)^2));
%
end
%%%%%% Define Eno%%%%%%%%%%%%%%
for i = 2:N
E(i,1) = (4 * sin(k(i)*b)) / (RI *k(i)* log(RE/RI) * cos(k(i)*h));
end
for i = 2:N
for j = 2:M
Rml_prime_RI = m(j)*(besselk(l, m(j)*RI) * dbesseli(l, m(j)*RI) …
– besseli(l, m(j)*RI) * dbesselk(l, m(j)*RI))…
/ (besselk(l, m(j)*RI) * besseli(l, m(j)*RE) – besselk(l, m(j)*RE) * besseli(l, m(j)*RI));
E(i,j) = Rml_prime_RI * (4 * k(i) * (-1)^(j-1) * sin(k(i)*b)) / (cos(k(i)*h) * (k(i)^2 – m(j)^2));
end
end
%%%%%%%%%%%%%%%%%%%%%%%% Now write matrix F %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
F = zeros(N,M);
%%%%%%%% Define F00 %%%%%%%%%%
F(1,1) = (-4 * sinh(wk*b)) / (RI * wk*log(RE/RI) * cosh(wk*h));
% %%%%%% Define F0m%%%%
for j = 2:M
Rml_star_prime_RI = m(j)*(besseli(l, m(j)*RE) * dbesselk(l, m(j)*RI) …
– besselk(l, m(j)*RE) * dbesseli(l, m(j)*RI))/((besselk(l, m(j)*RI) …
* besseli(l, m(j)*RE) – besselk(l, m(j)*RE) * besseli(l, m(j)*RI)));
F(1,j) = Rml_star_prime_RI * (4 * wk * (-1)^(j-1) * sinh(wk*b)) / (cosh(wk*h) * (wk^2 + m(j)^2));
end
%%%%% Defin Fn0%%%%%%
for i = 2:N
F(i,1) = (-4 * sin(k(i)*b)) / (RI *k(i)* log(RE/RI) * cos(k(i)*h));
end
%%%%%%% Define Fnm %%%%%%%
for i = 2:N
for j = 2:M
Rml_star_prime_RI = m(j)*(besseli(l, m(j)*RE) * dbesselk(l, m(j)*RI) …
– besselk(l, m(j)*RE) * dbesseli(l, m(j)*RI))/((besselk(l, m(j)*RI) …
* besseli(l, m(j)*RE) – besselk(l, m(j)*RE) * besseli(l, m(j)*RI)));
F(i,j) = Rml_star_prime_RI * (4 * k(i)* (-1)^(j-1) * sin(k(i)*b)) / (cos(k(i)*h) * (k(i)^2 – m(j)^2));
end
end
% % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% % Define right-hand side vector G
G = zeros(2*M+2*N, 1); % Total length = M + N+ M+ N = 2M+2N
%
% Block 1: G (size M = 4)
for i = 1:M
if i == 1
G(i, 1) = (sinh(wk*b))/((b*wk)*cosh(wk*h))*besselj(l, wk*RE) ; % Z_0^l
else
G(i, 1) = (2 *wk*(-1)^(i-1)*sinh(wk*b))/(b *(wk^2 +m(i)^2))*besselj(l, wk*RE); %Z_m^l
end
end
%
% Block 2: Y (size N = 3)
for j = 1:N
if j == 1
G(j + M, 1) = -dbesselj(l, wk*RE) * (2*wk*h + sinh(2*wk*h)) /(cosh(wk*h)^2); % Y_0^l
else
G(j + M, 1) = 0; % Y_n^l
end
end
% Block 3: X (size M = 4)
for i = 1:M
G(i + M + N, 1) = 0; % X_0^l, X_m^l
end
% Block 4: W (size N = 3)
for j = 1:N
G(j + M + N + M, 1) = 0; % W_0^l, W_n^l
end
% Identity matrices
I_M = eye(M);
I_N = eye(N);
% Zero matrices
ZMM = zeros(M, M);
ZMN = zeros(M, N);
ZNM = zeros(N, M);
ZNN = zeros(N, N);
% Construct the full block matrix H
H = [ I_M, -A, ZMM, ZMN; % Block row 1
-B, I_N, -C, ZNN; % Block row 2
ZMM, ZMN, I_M, -D; % Block row 3
-E, ZNN, -F, I_N]; % Block row 4
% X = H G; % Solve the linear system
X = pinv(H) * G; % Use pseudoinverse for stability
%
b_vec = X(1:M); % Coefficients b^l
a_vec = X(M+1 : M+N); % Coefficients a^l
c_vec = X(M+N+1 : 2*M+N); % Coefficients c^l
d_vec = X(2*M+N+1 : end); % Coefficients d^l
%%%%%%%%% Wave motion%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
term1 = (d_vec(1)*cosh(wk*h)^2) / ((2*wk*h + sinh(2*wk*h)) * dbesselj(l, wk*RI));
sum1 = 0;
for n =2:N
sum1 = sum1 + d_vec(n)*cos(k(n)*h)^2/ ((2*k(n)*h + sin(2*k(n)*h))* dbesseli(l, k(n)*RI));
end
eta0(idx) = abs(term1+sum1);
% % disp(k.’) % Should all be real and positive for n ≥ 2
% %
% %
end
plot(X_kRE, eta0, ‘k’, ‘LineWidth’, 1.5);
xlabel(‘$k_0 R_E$’, ‘Interpreter’, ‘latex’);
ylabel(‘$eta / (iA)$’, ‘Interpreter’, ‘latex’);
title(‘Wave motion amplitude for RE/RI = 4.0’);
grid on;
xlim([0 4]); % Match the reference plot
ylim([0 6]); % Optional: based on expected peak height
elapsedTime = toc;
disp([‘Time consuming = ‘, num2str(elapsedTime), ‘ s’]);
function out = dbesselh(l, z)
if l == 0
out = -besselh(1, 1, z);
else
out = 0.5 * (besselh(l – 1, 1, z) – besselh(l + 1, 1, z));
end
end
function out = dbesseli(l, z)
if l == 0
out = besseli(1, z);
else
out = 0.5 * (besseli(l – 1, z) + besseli(l + 1, z));
end
end
function out = dbesselj(l, z)
if l == 0
out = -besselj(1, z);
else
out = 0.5 * (besselj(l – 1, z) – besselj(l + 1, z));
end
end
function out = dbesselk(l, z)
if l == 0
out = -besselk(1, z);
else
out = -0.5 * (besselk(l – 1, z) + besselk(l + 1, z));
end
end I have the following code for my problem where i apply the match eigen function technique to find the unknown coefficients and then plotting one result wave motion inside a moonpool structure. However the expected plot for me should be decreasing after the resonance peak. But in my code it is decrease but then again blows up. I did not find any source of error. The analytical expressions which i used for my problem is write in pdf file at the end. Here is my code . I just want to figure out my source of error to fix it but i couldn’t. So I need help in acheiving my desired results. I also attached the refrence plot.
clear all;
close all;
clc;
tic;
% Parameters from your setup
N = 5; % Number of evanescent modes
M = 3; % Number of azimuthal modes
RE = 1.0; % Outer radius (m)
ratio = 2.0; % Ratio R_E / R_I
RI = RE / ratio; % Inner radius (m)
h = 4.0 * RE; % Water depth (m)
b = 2.0; % Distance from cylinder bottom to seabed (m)
d = h – b; % Interface depth (m)
g = 9.81; % Gravity (m/s^2)
l = 0; % Azimuthal order
% I_given_wavenumber = 1;
X_kRE = linspace(0.01, 4, 200);
% Initialize eta0 array before loop
eta0 = zeros(size(X_kRE)); % Preallocate
for idx = 1:length(X_kRE)
% if I_given_wavenumber == 1
wk = X_kRE(idx) / RE; % dimensional wavenumber
omega = sqrt(g * wk * tanh(wk * h)); % dispersion relation
fun_alpha = @(x) omega^2 + g*x.*tan(x*h); %dispersion equation for evanescent modes
for n = 1:N
if n == 1
k(n) = -1i * wk;
else
x0_left = (2*n – 3) * pi / (2*h);
x0_right = (2*n – 1) * pi / (2*h);
guess = (x0_left + x0_right)/2;
% Use lsqnonlin for better convergence
k(n) = lsqnonlin(fun_alpha, guess, x0_left, x0_right);
end
end
% % find evanescent modes k1…k_{N-1} stored in k_all(2)…k_all(N)
% for n = 2 : N
% m = n – 1; % mode index for evanescent
% a = ((2*m-1)*pi)/(2*h) + eps;
% b = (m*pi)/h – eps;
% % at a: tan→ -∞ so f(a)<0; at b: tan→0 so f(b)=+omega^2>0
% k_all(n) = fzero(@(k) g*k.*tan(k*h) + omega^2, [a, b]);
% end
% % % end
%% finding the root lemda_m =m*pi/b%%%%%%
for j=1:M
m(j)=(pi*(j-1))/b;
end
% %%%%%%%%%%%%%%%%%%%%% Define matrix A %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
A = zeros(M,N);
A(1,1) = (cosh(wk*h)*sinh(wk*b))/(wk*b*(2*wk*h+sinh(2*wk*h)))*(besselh(l, wk*RE)) /(dbesselh(l, wk*RE)); % Set A_00
for j = 2:N
A(1,j) =(cos(k(j)*h)*sin(k(j)*b) )/ (k(j)*b*(2*k(j)*h + sin(2*k(j)*h)))*( besselk(l, k(j)*RE) )…
/(dbesselk(l, k(j)*RE)); % Set A_0n
end
for i = 2:M
A(i,1) =(2 * cosh(wk*h) * (-1)^(i-1) * wk*sinh(wk*b)) / (b * (2*wk*h + sinh(2*wk*h))*(wk^2 + m(i)^2))…
* (besselh(l, wk*RE))/ (dbesselh(l, wk*RE)); % Set A_m0
end
for i = 2:M
for j = 2:N
A(i,j) = (2*cos(k(j)*h)*(-1)^(i-1) *k(j)* sin(k(j)*b))/ (b * (2*k(j)*h + sin(2*k(j)*h))*(k(j)^2-m(i)^2))…
*(besselk(l, k(j)*RE)) / (dbesselk(l, k(j)*RE));% Set A_mn
end
end
%%%%%%%%%%%%%%%%%%%%%%%% DefineMatrix B %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
B=zeros(N,M);
B(1,1) = (4*sinh(wk*b)) / (RE * wk*log(RE/RI) *cosh(wk*h)); %set B_00
%%%%%%%%%%%B_0m%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
for j = 2:M
Rml_prime_RE = m(j)*(besselk(l, m(j)*RI) * dbesseli(l, m(j)*RE) …
– besseli(l, m(j)*RI) * dbesselk(l, m(j)*RE))…
/(besselk(l, m(j)*RI) * besseli(l, m(j)*RE) – besselk(l, m(j)*RE) * besseli(l, m(j)*RI));
B(1,j) = Rml_prime_RE * (4 * wk * (-1)^(j-1) * sinh(wk*b)) / (cosh(wk*h) * (wk^2 + m(j)^2));
end
%%%%%%%%%%%B_n0%%%%%%%%%%%%%%%%%%%%%%%%%%%
for i=2:N
B(i,1)=(4*sin(k(i)*b))/(RE*k(i)*log(RE/RI)*cos(k(i)*h));% Set B_n0
end
%%%%%%%%%%%%%%%%%%%%%%%%%%B_nm%%%%%%%%%%%%%%%%%%%%%%%%%%%%
for i=2:N
for j=2:M
Rml_prime_RE = m(j)*(besselk(l, m(j)*RI) * dbesseli(l, m(j)*RE) …
– besseli(l, m(j)*RI) * dbesselk(l, m(j)*RE))…
/(besselk(l, m(j)*RI) * besseli(l, m(j)*RE) – besselk(l, m(j)*RE) * besseli(l, m(j)*RI));
B(i,j) = Rml_prime_RE * (4 * k(i) * (-1)^(j-1) * sin(k(i)*b)) / (cos(k(i)*h) * (k(i)^2 – m(j)^2));
end
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Define Matrix C %%%%%%%%%%%%%%%%%%%%%%%%
C = zeros(N,M);
C(1,1) = -4 * sinh(wk*b) / (RE * wk*log(RE/RI) * cosh(wk*h));
% %%%%% DEfine C0m%%%%%%
for j = 2:M
Rml_prime_star_RE = m(j)*(besseli(l, m(j)*RE) * dbesselk(l, m(j)*RE) …
– besselk(l, m(j)*RE) * dbesseli(l, m(j)*RE))…
/(besselk(l, m(j)*RI) * besseli(l, m(j)*RE) – besselk(l, m(j)*RE) * besseli(l, m(j)*RI));
C(1,j) = Rml_prime_star_RE * (4 * wk * (-1)^(j-1) * sinh(wk*b)) / (cosh(wk*h) * (wk^2 + m(j)^2));
end
% %%%%%%% Define Cn0%%%%%%
for i = 2:N
C(i,1) = -4 * sin(k(i)*b) / (RE *k(i)* log(RE/RI) * cos(k(i)*h));
end
% % %%%%%% Define Cnm%%%%%%
for i = 2:N
for j =2:M
Rml_prime_star_RE = m(j)*(besseli(l, m(j)*RE) * dbesselk(l, m(j)*RE) …
– besselk(l, m(j)*RE) * dbesseli(l, m(j)*RE))…
/(besselk(l, m(j)*RI) * besseli(l, m(j)*RE) – besselk(l, m(j)*RE) * besseli(l, m(j)*RI));
C(i,j) = Rml_prime_star_RE * (4 * k(i) * (-1)^(j-1) * sin(k(i)*b)) / (cos(k(i)*h) * (k(i)^2 – m(j)^2));
end
end
%%%%%%% write Matrix D %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
D = zeros(M,N);
%%% write D00 %%%%%%
D(1,1) = (cosh(wk*h) * sinh(wk*b)) / (wk*b * (2*wk*h + sinh(2*wk*h))) * (besselj(l, wk*RI))/ (dbesselj(l, wk*RI));
%%%%% write D0n %%%%%%%%%%
for j =2:N
D(1,j) = (cos(k(j)*h) * sin(k(j)*b)) / (k(j)*b * (2*k(j)*h + sin(2*k(j)*h))) * (besseli(l, k(j)*RI) )/ (dbesseli(l, k(j)*RI));
end
%%%%%% write Dm0 %%%%%%%%%
for i = 2:M
D(i,1) = (2 * cosh(wk*h) * (-1)^(i-1) * wk * sinh(wk*b)) /(b * (2*wk*h + sinh(2*wk*h)) * (wk^2 + m(i)^2))…
*(besselj(l, wk*RI) )/(dbesselj(l, wk*RI));
end
%%%%% Define Dmn%%%%%%%%
for i = 2:M
for j = 2:N
D(i,j) = (2 * cos(k(j)*h) * (-1)^(i-1) * k(j) * sin(k(j)*b)) /(b * (2*k(j)*h + sin(2*k(j)*h)) * (k(j)^2 – m(i)^2))…
*(besseli(l, k(j)*RI)) / (dbesseli(l, k(j)*RI));
end
end
%%%%%%%%%%%%%%%%%%%%%%%%%% Define Matrix E %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
E = zeros(N, M); % Preallocate the matrix E
%%%%% Define E00%%%%%%%%%%%%
E(1,1) = (4 * sinh(wk*b)) / (RI *wk* log(RE/RI) * cosh(wk*h));
%%%% Define Eom %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
for j = 2:M
Rml_prime_RI = m(j)*(besselk(l, m(j)*RI) * dbesseli(l, m(j)*RI) …
– besseli(l, m(j)*RI) * dbesselk(l, m(j)*RI))…
/ (besselk(l, m(j)*RI) * besseli(l, m(j)*RE) – besselk(l, m(j)*RE) * besseli(l, m(j)*RI));
E(1,j) = Rml_prime_RI * (4 * wk * (-1)^(j-1) * sinh(wk*b)) / (cosh(wk*h) * (wk^2 + m(j)^2));
%
end
%%%%%% Define Eno%%%%%%%%%%%%%%
for i = 2:N
E(i,1) = (4 * sin(k(i)*b)) / (RI *k(i)* log(RE/RI) * cos(k(i)*h));
end
for i = 2:N
for j = 2:M
Rml_prime_RI = m(j)*(besselk(l, m(j)*RI) * dbesseli(l, m(j)*RI) …
– besseli(l, m(j)*RI) * dbesselk(l, m(j)*RI))…
/ (besselk(l, m(j)*RI) * besseli(l, m(j)*RE) – besselk(l, m(j)*RE) * besseli(l, m(j)*RI));
E(i,j) = Rml_prime_RI * (4 * k(i) * (-1)^(j-1) * sin(k(i)*b)) / (cos(k(i)*h) * (k(i)^2 – m(j)^2));
end
end
%%%%%%%%%%%%%%%%%%%%%%%% Now write matrix F %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
F = zeros(N,M);
%%%%%%%% Define F00 %%%%%%%%%%
F(1,1) = (-4 * sinh(wk*b)) / (RI * wk*log(RE/RI) * cosh(wk*h));
% %%%%%% Define F0m%%%%
for j = 2:M
Rml_star_prime_RI = m(j)*(besseli(l, m(j)*RE) * dbesselk(l, m(j)*RI) …
– besselk(l, m(j)*RE) * dbesseli(l, m(j)*RI))/((besselk(l, m(j)*RI) …
* besseli(l, m(j)*RE) – besselk(l, m(j)*RE) * besseli(l, m(j)*RI)));
F(1,j) = Rml_star_prime_RI * (4 * wk * (-1)^(j-1) * sinh(wk*b)) / (cosh(wk*h) * (wk^2 + m(j)^2));
end
%%%%% Defin Fn0%%%%%%
for i = 2:N
F(i,1) = (-4 * sin(k(i)*b)) / (RI *k(i)* log(RE/RI) * cos(k(i)*h));
end
%%%%%%% Define Fnm %%%%%%%
for i = 2:N
for j = 2:M
Rml_star_prime_RI = m(j)*(besseli(l, m(j)*RE) * dbesselk(l, m(j)*RI) …
– besselk(l, m(j)*RE) * dbesseli(l, m(j)*RI))/((besselk(l, m(j)*RI) …
* besseli(l, m(j)*RE) – besselk(l, m(j)*RE) * besseli(l, m(j)*RI)));
F(i,j) = Rml_star_prime_RI * (4 * k(i)* (-1)^(j-1) * sin(k(i)*b)) / (cos(k(i)*h) * (k(i)^2 – m(j)^2));
end
end
% % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% % Define right-hand side vector G
G = zeros(2*M+2*N, 1); % Total length = M + N+ M+ N = 2M+2N
%
% Block 1: G (size M = 4)
for i = 1:M
if i == 1
G(i, 1) = (sinh(wk*b))/((b*wk)*cosh(wk*h))*besselj(l, wk*RE) ; % Z_0^l
else
G(i, 1) = (2 *wk*(-1)^(i-1)*sinh(wk*b))/(b *(wk^2 +m(i)^2))*besselj(l, wk*RE); %Z_m^l
end
end
%
% Block 2: Y (size N = 3)
for j = 1:N
if j == 1
G(j + M, 1) = -dbesselj(l, wk*RE) * (2*wk*h + sinh(2*wk*h)) /(cosh(wk*h)^2); % Y_0^l
else
G(j + M, 1) = 0; % Y_n^l
end
end
% Block 3: X (size M = 4)
for i = 1:M
G(i + M + N, 1) = 0; % X_0^l, X_m^l
end
% Block 4: W (size N = 3)
for j = 1:N
G(j + M + N + M, 1) = 0; % W_0^l, W_n^l
end
% Identity matrices
I_M = eye(M);
I_N = eye(N);
% Zero matrices
ZMM = zeros(M, M);
ZMN = zeros(M, N);
ZNM = zeros(N, M);
ZNN = zeros(N, N);
% Construct the full block matrix H
H = [ I_M, -A, ZMM, ZMN; % Block row 1
-B, I_N, -C, ZNN; % Block row 2
ZMM, ZMN, I_M, -D; % Block row 3
-E, ZNN, -F, I_N]; % Block row 4
% X = H G; % Solve the linear system
X = pinv(H) * G; % Use pseudoinverse for stability
%
b_vec = X(1:M); % Coefficients b^l
a_vec = X(M+1 : M+N); % Coefficients a^l
c_vec = X(M+N+1 : 2*M+N); % Coefficients c^l
d_vec = X(2*M+N+1 : end); % Coefficients d^l
%%%%%%%%% Wave motion%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
term1 = (d_vec(1)*cosh(wk*h)^2) / ((2*wk*h + sinh(2*wk*h)) * dbesselj(l, wk*RI));
sum1 = 0;
for n =2:N
sum1 = sum1 + d_vec(n)*cos(k(n)*h)^2/ ((2*k(n)*h + sin(2*k(n)*h))* dbesseli(l, k(n)*RI));
end
eta0(idx) = abs(term1+sum1);
% % disp(k.’) % Should all be real and positive for n ≥ 2
% %
% %
end
plot(X_kRE, eta0, ‘k’, ‘LineWidth’, 1.5);
xlabel(‘$k_0 R_E$’, ‘Interpreter’, ‘latex’);
ylabel(‘$eta / (iA)$’, ‘Interpreter’, ‘latex’);
title(‘Wave motion amplitude for RE/RI = 4.0’);
grid on;
xlim([0 4]); % Match the reference plot
ylim([0 6]); % Optional: based on expected peak height
elapsedTime = toc;
disp([‘Time consuming = ‘, num2str(elapsedTime), ‘ s’]);
function out = dbesselh(l, z)
if l == 0
out = -besselh(1, 1, z);
else
out = 0.5 * (besselh(l – 1, 1, z) – besselh(l + 1, 1, z));
end
end
function out = dbesseli(l, z)
if l == 0
out = besseli(1, z);
else
out = 0.5 * (besseli(l – 1, z) + besseli(l + 1, z));
end
end
function out = dbesselj(l, z)
if l == 0
out = -besselj(1, z);
else
out = 0.5 * (besselj(l – 1, z) – besselj(l + 1, z));
end
end
function out = dbesselk(l, z)
if l == 0
out = -besselk(1, z);
else
out = -0.5 * (besselk(l – 1, z) + besselk(l + 1, z));
end
end moonpool, resonance, system of linear equation, semi analytical solution, wave motion MATLAB Answers — New Questions
How we can calculculate the MTF from PSF?
I want to calculate the MTF from this PSF.I want to calculate the MTF from this PSF. I want to calculate the MTF from this PSF. frequency MATLAB Answers — New Questions
The provided solution is coming up as incorrect.
I am currently doing the MATLAB onramp course and I am on task 6 of the final project Stellar moon 2 and I cant figure out the answer. When I select the solution I copied it and put it as my answer however it comes up as incorrect. This is beyond frusterating as I am unable to progress and I have tried deleting everything and trying again several times and I just want to finish this course. Can someone please help.I am currently doing the MATLAB onramp course and I am on task 6 of the final project Stellar moon 2 and I cant figure out the answer. When I select the solution I copied it and put it as my answer however it comes up as incorrect. This is beyond frusterating as I am unable to progress and I have tried deleting everything and trying again several times and I just want to finish this course. Can someone please help. I am currently doing the MATLAB onramp course and I am on task 6 of the final project Stellar moon 2 and I cant figure out the answer. When I select the solution I copied it and put it as my answer however it comes up as incorrect. This is beyond frusterating as I am unable to progress and I have tried deleting everything and trying again several times and I just want to finish this course. Can someone please help. solve, onramp MATLAB Answers — New Questions
speeding up the data analysis
I am working on a project where I have to analyse high frequency wind data (50 Hz) coming from a wind turbine data measurement system. this amount of data must be converted from .dat binary files to .mat files which I can use in matlab. The data must then be filtered and then averaged over 10 minutes to be compared to the data from another measurement system. Doing all this requires the analysis of thousands of data and it’s very time consuming (right now it is about 105 seconds just for the data of 2 days). How can I speed the process up?
for ii = 3:length(filedir)
filename = filedir(ii).name;
newdata = ReadFamosDataIntoTimeTable(filename);
% filter
IsConsidered = newdata.avbladeangleGRe<40 … % normal operation
& newdata.RAWS9>0.5 … % good availability
& ~isnan(newdata.iv10mswindspeed2GRe) & newdata.av100msabswinddirectionGRe>180 & newdata.av100msabswinddirectionGRe<250;
TurbineData(ii-2).date = filename;
TurbineData(ii-2).iv10mswindspeed2GRe = mean(newdata.iv10mswindspeed2GRe(IsConsidered));
TurbineData(ii-2).ivactivepowerGRe = mean(newdata.ivactivepowerGRe(IsConsidered));
TurbineData(ii-2).CalculatedAirdensity_GRe = mean(newdata.CalculatedAirdensity_GRe(IsConsidered));
TurbineData(ii-2).HWShub1 = mean(newdata.HWShub1(IsConsidered));
TurbineData(ii-2).av100msabswinddirectionGRe = mean(newdata.av100msabswinddirectionGRe(IsConsidered));
end
The function ReadFamosDataIntoTimeTable is to convert the .dat binary data into .mat dataI am working on a project where I have to analyse high frequency wind data (50 Hz) coming from a wind turbine data measurement system. this amount of data must be converted from .dat binary files to .mat files which I can use in matlab. The data must then be filtered and then averaged over 10 minutes to be compared to the data from another measurement system. Doing all this requires the analysis of thousands of data and it’s very time consuming (right now it is about 105 seconds just for the data of 2 days). How can I speed the process up?
for ii = 3:length(filedir)
filename = filedir(ii).name;
newdata = ReadFamosDataIntoTimeTable(filename);
% filter
IsConsidered = newdata.avbladeangleGRe<40 … % normal operation
& newdata.RAWS9>0.5 … % good availability
& ~isnan(newdata.iv10mswindspeed2GRe) & newdata.av100msabswinddirectionGRe>180 & newdata.av100msabswinddirectionGRe<250;
TurbineData(ii-2).date = filename;
TurbineData(ii-2).iv10mswindspeed2GRe = mean(newdata.iv10mswindspeed2GRe(IsConsidered));
TurbineData(ii-2).ivactivepowerGRe = mean(newdata.ivactivepowerGRe(IsConsidered));
TurbineData(ii-2).CalculatedAirdensity_GRe = mean(newdata.CalculatedAirdensity_GRe(IsConsidered));
TurbineData(ii-2).HWShub1 = mean(newdata.HWShub1(IsConsidered));
TurbineData(ii-2).av100msabswinddirectionGRe = mean(newdata.av100msabswinddirectionGRe(IsConsidered));
end
The function ReadFamosDataIntoTimeTable is to convert the .dat binary data into .mat data I am working on a project where I have to analyse high frequency wind data (50 Hz) coming from a wind turbine data measurement system. this amount of data must be converted from .dat binary files to .mat files which I can use in matlab. The data must then be filtered and then averaged over 10 minutes to be compared to the data from another measurement system. Doing all this requires the analysis of thousands of data and it’s very time consuming (right now it is about 105 seconds just for the data of 2 days). How can I speed the process up?
for ii = 3:length(filedir)
filename = filedir(ii).name;
newdata = ReadFamosDataIntoTimeTable(filename);
% filter
IsConsidered = newdata.avbladeangleGRe<40 … % normal operation
& newdata.RAWS9>0.5 … % good availability
& ~isnan(newdata.iv10mswindspeed2GRe) & newdata.av100msabswinddirectionGRe>180 & newdata.av100msabswinddirectionGRe<250;
TurbineData(ii-2).date = filename;
TurbineData(ii-2).iv10mswindspeed2GRe = mean(newdata.iv10mswindspeed2GRe(IsConsidered));
TurbineData(ii-2).ivactivepowerGRe = mean(newdata.ivactivepowerGRe(IsConsidered));
TurbineData(ii-2).CalculatedAirdensity_GRe = mean(newdata.CalculatedAirdensity_GRe(IsConsidered));
TurbineData(ii-2).HWShub1 = mean(newdata.HWShub1(IsConsidered));
TurbineData(ii-2).av100msabswinddirectionGRe = mean(newdata.av100msabswinddirectionGRe(IsConsidered));
end
The function ReadFamosDataIntoTimeTable is to convert the .dat binary data into .mat data optimization, for loop, speed, data conversion MATLAB Answers — New Questions