Month: July 2024
How to convert signal data type by using function or code script
Is there a function or code script to change the signal data type of signal editor InputScenario in test harness like the following picture shows:Is there a function or code script to change the signal data type of signal editor InputScenario in test harness like the following picture shows: Is there a function or code script to change the signal data type of signal editor InputScenario in test harness like the following picture shows: signal editor MATLAB Answers — New Questions
Excel hyperlink default software to open FileName .pdf
A hyperlink to a “.pdf” type file is created in an excel cell.
Clicking on this hyperlink opens the file.
The problem is that the default software to do this is Adobe Acrobat not the default software I have set in my Settings > Apps > Default Apps.
It seems that Excel has a mind of its own when it comes to this function/action (Opening a Hyperlink to a “.pdf ” file elsewhere in the computer).
This is a new recent problem as for many years the default setting was always used.
How to get excel to use the default software as it used to do? Help please!
A hyperlink to a “.pdf” type file is created in an excel cell.Clicking on this hyperlink opens the file.The problem is that the default software to do this is Adobe Acrobat not the default software I have set in my Settings > Apps > Default Apps.It seems that Excel has a mind of its own when it comes to this function/action (Opening a Hyperlink to a “.pdf ” file elsewhere in the computer).This is a new recent problem as for many years the default setting was always used.How to get excel to use the default software as it used to do? Help please! Read More
Formulas and Functions copy an array from sheet 1 to sheet2.
I want to type a number into a cell on sheet 2. Then lookup that number on sheet 1 (column A). Then select the horizontal array for this number columns B:F. Insert the selected array into sheet 2 in columns C:G. The typed number varies from 1 to 146.
I want to type a number into a cell on sheet 2. Then lookup that number on sheet 1 (column A). Then select the horizontal array for this number columns B:F. Insert the selected array into sheet 2 in columns C:G. The typed number varies from 1 to 146. Read More
How to Fix Quick_books won’t open on windows 10/11?
If Quick_Books won’t open on your Windows 10 or 11 computer, there could be various underlying issues. Here are steps to troubleshoot and resolve the problem:
1. Restart Your Computer
Sometimes, a simple restart can resolve many issues. Restart your computer and try opening Quick_Books again.
2. Run Quick_Books as Administrator
Right-click on the Quick_Books icon.Select “Run as administrator.”
3. Suppress the Quick_Books Desktop Application
Press and hold the Ctrl key.Double-click the Quick_Books icon while holding the Ctrl key.Hold the key until Quick_Books opens or you see the “No Company Open” window.
4. Use Quick_Books Tool Hub
Download and install the Quick_Books Tool Hub from the official Intuit website.Open the Tool Hub and select “Program Problems.”Click on “Quick Fix my Program.”
5. Run Quick_Books Install Diagnostic Tool
Open Quick_Books Tool Hub.Go to the “Installation Issues” tab.Select “Quick_Books Install Diagnostic Tool” and let it run. This tool will check and repair any installation issues.
6. Rename the QBWUSER.ini File
Locate the QBWUSER.ini file (usually found in the Quick_Books folder in the AppData directory).Right-click the file and select “Rename.”Add .old to the end of the file name (e.g., QBWUSER.ini.old).Try opening Quick_Books again. If it opens, you will need to re-open your company file manually.
7. Check Compatibility Mode
Right-click the Quick_Books icon.Select “Properties.”Go to the “Compatibility” tab.Ensure that the compatibility mode is unchecked.
8. Repair Quick_Books Installation
Go to the Control Panel.Select “Programs and Features.”Find Quick_Books in the list, select it, and click “Repair.”
9. Update Windows and Quick_Books
Ensure that your Windows operating system is up to date.Open Quick_Books and go to the Help menu, then select “Update Quick_Books Desktop.”Follow the prompts to update Quick_Books.
10. Disable Antivirus Software Temporarily
Sometimes, antivirus software can interfere with Quick_Books.Temporarily disable your antivirus software and try opening Quick_Books.
11. Check User Permissions
Ensure you have the correct user permissions to run Quick_Books.Right-click the Quick_Books icon and select “Properties.”Go to the “Security” tab and check that your user account has full control.
12. Reinstall Quick_Books Using Clean Install
Uninstall Quick_Books via the Control Panel.Use the Quick_Books Clean Install Tool from the Tool Hub.Reinstall Quick_Books using the original installation files or CD.
If none of these solutions work, contact Quick_Books support
If Quick_Books won’t open on your Windows 10 or 11 computer, there could be various underlying issues. Here are steps to troubleshoot and resolve the problem:1. Restart Your ComputerSometimes, a simple restart can resolve many issues. Restart your computer and try opening Quick_Books again.2. Run Quick_Books as AdministratorRight-click on the Quick_Books icon.Select “Run as administrator.”3. Suppress the Quick_Books Desktop ApplicationPress and hold the Ctrl key.Double-click the Quick_Books icon while holding the Ctrl key.Hold the key until Quick_Books opens or you see the “No Company Open” window.4. Use Quick_Books Tool HubDownload and install the Quick_Books Tool Hub from the official Intuit website.Open the Tool Hub and select “Program Problems.”Click on “Quick Fix my Program.”5. Run Quick_Books Install Diagnostic ToolOpen Quick_Books Tool Hub.Go to the “Installation Issues” tab.Select “Quick_Books Install Diagnostic Tool” and let it run. This tool will check and repair any installation issues.6. Rename the QBWUSER.ini FileLocate the QBWUSER.ini file (usually found in the Quick_Books folder in the AppData directory).Right-click the file and select “Rename.”Add .old to the end of the file name (e.g., QBWUSER.ini.old).Try opening Quick_Books again. If it opens, you will need to re-open your company file manually.7. Check Compatibility ModeRight-click the Quick_Books icon.Select “Properties.”Go to the “Compatibility” tab.Ensure that the compatibility mode is unchecked.8. Repair Quick_Books InstallationGo to the Control Panel.Select “Programs and Features.”Find Quick_Books in the list, select it, and click “Repair.”9. Update Windows and Quick_BooksEnsure that your Windows operating system is up to date.Open Quick_Books and go to the Help menu, then select “Update Quick_Books Desktop.”Follow the prompts to update Quick_Books.10. Disable Antivirus Software TemporarilySometimes, antivirus software can interfere with Quick_Books.Temporarily disable your antivirus software and try opening Quick_Books.11. Check User PermissionsEnsure you have the correct user permissions to run Quick_Books.Right-click the Quick_Books icon and select “Properties.”Go to the “Security” tab and check that your user account has full control.12. Reinstall Quick_Books Using Clean InstallUninstall Quick_Books via the Control Panel.Use the Quick_Books Clean Install Tool from the Tool Hub.Reinstall Quick_Books using the original installation files or CD.If none of these solutions work, contact Quick_Books support Read More
Deforming sheet into conical structure
I am trying to deform a flat sheet into a conical structure using MATLAB. (Pls see the image below)
L = length of sheet; R= bigger radius; r = smaller radius
Here’s my approach:
First i create an upward ramp (as shown in the image above), with a displacement in z-direction given by:
u_1 = r/L * (pi-1) * x
2. Then curve the edges of rectangular sheet into the conical form, given by displacements:
3. Hence the net displacement of any point becomes u_1 + u_2.
I have written this as a matlab code:
for i=1:length(A)
A(i,2) = A(i,2) + (sqrt(2*A(i,3)*r – A(i,3)*A(i,3))-A(i,2))*(A(i,1)/L);
A(i,3) = A(i,3) + ((r/L)*(pi-1)*(A(i,1)) + (R-sqrt(R*R – A(i,2)*A(i,2))*(1-(A(i,1)/L))) + ((R-r)+ (2/pi)*A(i,2))*(A(i,1)/L));
A here is the matrix with initial coordinates of the flat sheet. Then using a for loop, i apply the u_1 + u_2 displacement, changing the y and z coordinates of the sheet.
However, after running the code, i get one side to be very nicely fitting the curvature of the cone, whereas on the other side, all the points coincide at one single point rather than forming a circular face. Please see the images below.
Original flat sheet
Curved conical sheet with the issue
Can someone please help me with this?I am trying to deform a flat sheet into a conical structure using MATLAB. (Pls see the image below)
L = length of sheet; R= bigger radius; r = smaller radius
Here’s my approach:
First i create an upward ramp (as shown in the image above), with a displacement in z-direction given by:
u_1 = r/L * (pi-1) * x
2. Then curve the edges of rectangular sheet into the conical form, given by displacements:
3. Hence the net displacement of any point becomes u_1 + u_2.
I have written this as a matlab code:
for i=1:length(A)
A(i,2) = A(i,2) + (sqrt(2*A(i,3)*r – A(i,3)*A(i,3))-A(i,2))*(A(i,1)/L);
A(i,3) = A(i,3) + ((r/L)*(pi-1)*(A(i,1)) + (R-sqrt(R*R – A(i,2)*A(i,2))*(1-(A(i,1)/L))) + ((R-r)+ (2/pi)*A(i,2))*(A(i,1)/L));
A here is the matrix with initial coordinates of the flat sheet. Then using a for loop, i apply the u_1 + u_2 displacement, changing the y and z coordinates of the sheet.
However, after running the code, i get one side to be very nicely fitting the curvature of the cone, whereas on the other side, all the points coincide at one single point rather than forming a circular face. Please see the images below.
Original flat sheet
Curved conical sheet with the issue
Can someone please help me with this? I am trying to deform a flat sheet into a conical structure using MATLAB. (Pls see the image below)
L = length of sheet; R= bigger radius; r = smaller radius
Here’s my approach:
First i create an upward ramp (as shown in the image above), with a displacement in z-direction given by:
u_1 = r/L * (pi-1) * x
2. Then curve the edges of rectangular sheet into the conical form, given by displacements:
3. Hence the net displacement of any point becomes u_1 + u_2.
I have written this as a matlab code:
for i=1:length(A)
A(i,2) = A(i,2) + (sqrt(2*A(i,3)*r – A(i,3)*A(i,3))-A(i,2))*(A(i,1)/L);
A(i,3) = A(i,3) + ((r/L)*(pi-1)*(A(i,1)) + (R-sqrt(R*R – A(i,2)*A(i,2))*(1-(A(i,1)/L))) + ((R-r)+ (2/pi)*A(i,2))*(A(i,1)/L));
A here is the matrix with initial coordinates of the flat sheet. Then using a for loop, i apply the u_1 + u_2 displacement, changing the y and z coordinates of the sheet.
However, after running the code, i get one side to be very nicely fitting the curvature of the cone, whereas on the other side, all the points coincide at one single point rather than forming a circular face. Please see the images below.
Original flat sheet
Curved conical sheet with the issue
Can someone please help me with this? deformation MATLAB Answers — New Questions
Excuse me, could you help me correctly name my Vcm1, Vcm2, Vcm3, Vcm4 in num2str?
grid on
xlabel(‘X’)
ylabel(‘Y’)
zlabel(‘Z’)
title([‘Tiempo de ‘,num2str(t(i)),’s’],’FontSize’,18)
axis([-60,60,-60,60,0,60])
legend(‘Eslabón 1′,’Eslabón 2′,’Eslabón 3′,’Eslabón 4′,’FontSize’,16)
dim = ([0.8 0.4 0.1 0.2])
annotation(‘textbox’,dim,’String’,num2str([‘Vcm1′,’Vcm2′,’Vcm3′,’Vcm4’]), ‘FontSize’;15) Invalid expression.
view(100,35)
pause(0.01)grid on
xlabel(‘X’)
ylabel(‘Y’)
zlabel(‘Z’)
title([‘Tiempo de ‘,num2str(t(i)),’s’],’FontSize’,18)
axis([-60,60,-60,60,0,60])
legend(‘Eslabón 1′,’Eslabón 2′,’Eslabón 3′,’Eslabón 4′,’FontSize’,16)
dim = ([0.8 0.4 0.1 0.2])
annotation(‘textbox’,dim,’String’,num2str([‘Vcm1′,’Vcm2′,’Vcm3′,’Vcm4’]), ‘FontSize’;15) Invalid expression.
view(100,35)
pause(0.01) grid on
xlabel(‘X’)
ylabel(‘Y’)
zlabel(‘Z’)
title([‘Tiempo de ‘,num2str(t(i)),’s’],’FontSize’,18)
axis([-60,60,-60,60,0,60])
legend(‘Eslabón 1′,’Eslabón 2′,’Eslabón 3′,’Eslabón 4′,’FontSize’,16)
dim = ([0.8 0.4 0.1 0.2])
annotation(‘textbox’,dim,’String’,num2str([‘Vcm1′,’Vcm2′,’Vcm3′,’Vcm4’]), ‘FontSize’;15) Invalid expression.
view(100,35)
pause(0.01) vcm, num2str MATLAB Answers — New Questions
How do I download YouTube videos in laptop Windows 10
Hi, everyone, I have a headache right now, and I hope friends here can help me. I use a Windows 10 laptop, and recently I want to download YouTube videos to desktop computer, so that I can watch them when I don’t have an Internet connection. I tried several online download sites and browser plug-ins, but none of them worked. Either the download speed was unbearably slow, or the quality of the downloaded videos was ridiculously poor.
I really need a good method to solve this problem, and I hope friends with experience can share it, thank you very much!
Hi, everyone, I have a headache right now, and I hope friends here can help me. I use a Windows 10 laptop, and recently I want to download YouTube videos to desktop computer, so that I can watch them when I don’t have an Internet connection. I tried several online download sites and browser plug-ins, but none of them worked. Either the download speed was unbearably slow, or the quality of the downloaded videos was ridiculously poor. I really need a good method to solve this problem, and I hope friends with experience can share it, thank you very much! Read More
export the “To”, “From” & “cc” fields in the public folders to csv files
We have a load of our email stored in Public Folders with sub-folders, year-wise. Is it possible to export/extract the contacts (from, to & cc) from each email in the public folders and sub-folders to a scv excel file?
We have a load of our email stored in Public Folders with sub-folders, year-wise. Is it possible to export/extract the contacts (from, to & cc) from each email in the public folders and sub-folders to a scv excel file? Read More
Whom to report when several days after a ‘file submission’ displayed status is ‘In progress’…
Hello all,
could anyone be so kind to tell me whom should I report these issues to, when :
– after several days (since submission took place on June 29, 2024) reported Status for same below mentioned ‘Submission ID’ is still displayed as ‘In progress’ ?
– no details for an already Submitted ‘File submission’ are available (because after clicking on ‘ 90d794a0-3a0d-4bc2-9d8f-2169d477fb30‘ only this error message is shown ‘The details for the submission were not found or the submission has expired. You can view recent items in your submission history.‘) ?
P.S. If I’d rather (better) submit this post/question into another Discussion Space then please just let me know ASAP.
Below you find a screenshot showing main issue I described. Please also note that I also already tried to report same main issue same day of submission and also today via same ‘Provide feedback’ smiley icon(also shown in screenshot below and evidenced in a squared box) but with no results so far.
Thanks in advance for any update.
Best Regards
Rob
Hello all, could anyone be so kind to tell me whom should I report these issues to, when :- after several days (since submission took place on June 29, 2024) reported Status for same below mentioned ‘Submission ID’ is still displayed as ‘In progress’ ?- no details for an already Submitted ‘File submission’ are available (because after clicking on ‘ 90d794a0-3a0d-4bc2-9d8f-2169d477fb30’ only this error message is shown ‘The details for the submission were not found or the submission has expired. You can view recent items in your submission history.’) ? P.S. If I’d rather (better) submit this post/question into another Discussion Space then please just let me know ASAP.Below you find a screenshot showing main issue I described. Please also note that I also already tried to report same main issue same day of submission and also today via same ‘Provide feedback’ smiley icon(also shown in screenshot below and evidenced in a squared box) but with no results so far.Thanks in advance for any update. Best RegardsRob Read More
Why use ‘delay’ for estimating a path for ANC?[simulink]
And, What is the difference between using delay and not using it when estimating a path for ANC?
The filter will already cause significant delay, so should I use it?
Thank you for your interest!
https://kr.mathworks.com/help/audio/ug/active-noise-control-with-simulink.htmlAnd, What is the difference between using delay and not using it when estimating a path for ANC?
The filter will already cause significant delay, so should I use it?
Thank you for your interest!
https://kr.mathworks.com/help/audio/ug/active-noise-control-with-simulink.html And, What is the difference between using delay and not using it when estimating a path for ANC?
The filter will already cause significant delay, so should I use it?
Thank you for your interest!
https://kr.mathworks.com/help/audio/ug/active-noise-control-with-simulink.html anc, fir, simulink MATLAB Answers — New Questions
Is it possible to utilize the sound recorded on ‘matlab mobile’ during simulink real time simulation?
I’m going to implement ANC for the location of my mobile phone through ‘Simulink’.
Mobile phones’ mic sensor will replace the role of microphones in this model.
https://kr.mathworks.com/help/audio/ug/active-noise-control-with-simulink.html?s_eid=PSM_15028
Is it possible? then what should i do?I’m going to implement ANC for the location of my mobile phone through ‘Simulink’.
Mobile phones’ mic sensor will replace the role of microphones in this model.
https://kr.mathworks.com/help/audio/ug/active-noise-control-with-simulink.html?s_eid=PSM_15028
Is it possible? then what should i do? I’m going to implement ANC for the location of my mobile phone through ‘Simulink’.
Mobile phones’ mic sensor will replace the role of microphones in this model.
https://kr.mathworks.com/help/audio/ug/active-noise-control-with-simulink.html?s_eid=PSM_15028
Is it possible? then what should i do? anc, mobile, simulink, real time MATLAB Answers — New Questions
Computer uses only 21% of cpu when running multithreading in simulink
I made a simulink spice model for a circuit and it is taking around 30 minutes to compile, I thought it was normal, but checking windows task manager it seems that only one thread of my cpu is at it’s maximum capacity, i tried using different configurations of workers and threads per worker, but nothing work it is still using arount 21% of the total of my CPU.
My simulink model has only one .slx
I am using this code for the parallel computing part
bdclose all;
%proj = openProject(‘.C:UsersfernaDownloadshalfBridgeTest.slx’);
model = ‘DownloadshalfBridgeTest.slx’;
open_system(model);
modelN = ‘halfBridgeTest’;
in = Simulink.SimulationInput(modelN);
parpool(‘LocalProfile1’)
tic; out = parsim(in, ‘UseFastRestart’,’on’); toc
delete(gcp(‘nocreate’));I made a simulink spice model for a circuit and it is taking around 30 minutes to compile, I thought it was normal, but checking windows task manager it seems that only one thread of my cpu is at it’s maximum capacity, i tried using different configurations of workers and threads per worker, but nothing work it is still using arount 21% of the total of my CPU.
My simulink model has only one .slx
I am using this code for the parallel computing part
bdclose all;
%proj = openProject(‘.C:UsersfernaDownloadshalfBridgeTest.slx’);
model = ‘DownloadshalfBridgeTest.slx’;
open_system(model);
modelN = ‘halfBridgeTest’;
in = Simulink.SimulationInput(modelN);
parpool(‘LocalProfile1’)
tic; out = parsim(in, ‘UseFastRestart’,’on’); toc
delete(gcp(‘nocreate’)); I made a simulink spice model for a circuit and it is taking around 30 minutes to compile, I thought it was normal, but checking windows task manager it seems that only one thread of my cpu is at it’s maximum capacity, i tried using different configurations of workers and threads per worker, but nothing work it is still using arount 21% of the total of my CPU.
My simulink model has only one .slx
I am using this code for the parallel computing part
bdclose all;
%proj = openProject(‘.C:UsersfernaDownloadshalfBridgeTest.slx’);
model = ‘DownloadshalfBridgeTest.slx’;
open_system(model);
modelN = ‘halfBridgeTest’;
in = Simulink.SimulationInput(modelN);
parpool(‘LocalProfile1’)
tic; out = parsim(in, ‘UseFastRestart’,’on’); toc
delete(gcp(‘nocreate’)); parallel computing, parallel computing toolbox, simulink MATLAB Answers — New Questions
inverse LaPlace transform of confluent hypergeometric function
hello, I want to calculate the inverse laplace transform of a characteristic function
this is the fourier transform of h(x), which is converted to Laplace transform with p = -i*t
from here we make a characteristic function which is
this characteristic function is converted to hypergeometric function
I have to get the inverse laplace transform of this function, I have written the following code:
N = 3; x_bar = 2.5; a = 1.3; b = 13; c = a+b;
syms s t
p = -1*1j*s
z = -1*((N*x_bar*(c/a)*p)/(p+1))
h = hypergeom(a,c,z)
C_slow = h/((p+1)^N)
f(t) = ilaplace(C_slow)
output of code:
z =
-(s*165i)/(2*(- 1 + s*1i))
h =
hypergeom(13/10, 143/10, -(s*165i)/(2*(- 1 + s*1i)))
do we have to put the vlaue of ”s” to evalute the hypergeom function? I don’t know what i am missing here…any help would be appreciatedhello, I want to calculate the inverse laplace transform of a characteristic function
this is the fourier transform of h(x), which is converted to Laplace transform with p = -i*t
from here we make a characteristic function which is
this characteristic function is converted to hypergeometric function
I have to get the inverse laplace transform of this function, I have written the following code:
N = 3; x_bar = 2.5; a = 1.3; b = 13; c = a+b;
syms s t
p = -1*1j*s
z = -1*((N*x_bar*(c/a)*p)/(p+1))
h = hypergeom(a,c,z)
C_slow = h/((p+1)^N)
f(t) = ilaplace(C_slow)
output of code:
z =
-(s*165i)/(2*(- 1 + s*1i))
h =
hypergeom(13/10, 143/10, -(s*165i)/(2*(- 1 + s*1i)))
do we have to put the vlaue of ”s” to evalute the hypergeom function? I don’t know what i am missing here…any help would be appreciated hello, I want to calculate the inverse laplace transform of a characteristic function
this is the fourier transform of h(x), which is converted to Laplace transform with p = -i*t
from here we make a characteristic function which is
this characteristic function is converted to hypergeometric function
I have to get the inverse laplace transform of this function, I have written the following code:
N = 3; x_bar = 2.5; a = 1.3; b = 13; c = a+b;
syms s t
p = -1*1j*s
z = -1*((N*x_bar*(c/a)*p)/(p+1))
h = hypergeom(a,c,z)
C_slow = h/((p+1)^N)
f(t) = ilaplace(C_slow)
output of code:
z =
-(s*165i)/(2*(- 1 + s*1i))
h =
hypergeom(13/10, 143/10, -(s*165i)/(2*(- 1 + s*1i)))
do we have to put the vlaue of ”s” to evalute the hypergeom function? I don’t know what i am missing here…any help would be appreciated laplace transform, hypergeometric function, swerling characteristic function MATLAB Answers — New Questions
Why such a fuss with ndgrid and meshgrid issues?
Folks,
In the world of artificial intelligence and more intelligent programming, I would like to see more intelligence put into place with how function like griddata, imagesc, pcolor, and surf interpret their inputs. There is an unfortunate degree of confusion that has persisted since the early 2000’s at least with how to interpret arrays in terms of Cartesian axes. I am troubled today with trying to understand how griddata is working on input that I setup using ndgrid. I appear to have something wrong, and earth layers are not dipping in the direction that I expect. The documentation says griddata can work with either meshgrid or griddata input, which makes my head spin given my understanding of both meshgrid and ndgrid. What is really troubling is that the Mathworks documentation routinely contains only simple examples where the person that created the documentation made "quicky" non-realistic examples where they simply created input arrays that had exactly the same x and y dimensions, which does not help anyone in my situation who is dealing with realistic inputs that do not have the same dimension lengths. I request that future documentation efforts spend a little extra time making non-symmetric input x and y arrays as examples.Folks,
In the world of artificial intelligence and more intelligent programming, I would like to see more intelligence put into place with how function like griddata, imagesc, pcolor, and surf interpret their inputs. There is an unfortunate degree of confusion that has persisted since the early 2000’s at least with how to interpret arrays in terms of Cartesian axes. I am troubled today with trying to understand how griddata is working on input that I setup using ndgrid. I appear to have something wrong, and earth layers are not dipping in the direction that I expect. The documentation says griddata can work with either meshgrid or griddata input, which makes my head spin given my understanding of both meshgrid and ndgrid. What is really troubling is that the Mathworks documentation routinely contains only simple examples where the person that created the documentation made "quicky" non-realistic examples where they simply created input arrays that had exactly the same x and y dimensions, which does not help anyone in my situation who is dealing with realistic inputs that do not have the same dimension lengths. I request that future documentation efforts spend a little extra time making non-symmetric input x and y arrays as examples. Folks,
In the world of artificial intelligence and more intelligent programming, I would like to see more intelligence put into place with how function like griddata, imagesc, pcolor, and surf interpret their inputs. There is an unfortunate degree of confusion that has persisted since the early 2000’s at least with how to interpret arrays in terms of Cartesian axes. I am troubled today with trying to understand how griddata is working on input that I setup using ndgrid. I appear to have something wrong, and earth layers are not dipping in the direction that I expect. The documentation says griddata can work with either meshgrid or griddata input, which makes my head spin given my understanding of both meshgrid and ndgrid. What is really troubling is that the Mathworks documentation routinely contains only simple examples where the person that created the documentation made "quicky" non-realistic examples where they simply created input arrays that had exactly the same x and y dimensions, which does not help anyone in my situation who is dealing with realistic inputs that do not have the same dimension lengths. I request that future documentation efforts spend a little extra time making non-symmetric input x and y arrays as examples. meshgrid, ndgrid, imagesc, pcolor, surf, griddata, slice, obliqueslice MATLAB Answers — New Questions
Can’t select multiple items with ctrl-click
Hi,
MS has changed mouse behavior in New Outlook. This seems an unusual move because PC users generally know how to use their keyboard and mouse – and have done for ~40 years. ctrl – left-click has, as long as I can remember, always enabled the user to select multiple items – text, files etc. But in New Outlook (not other MS programs) this has been disabled. This is a fundamental GUI operation. I can only imagine that the developer responsible has not been using PCs very much (or very long). Perhaps they are only accustomed to touch screens and / or are a very young child?
The mouse behavior has also been changed for activating pop-up options, namely spell-check, which is now left-click (was right click). This means that roughly 2 billion users accustomed to spell checking / using pop-up edit menus now have the inconvenience of learning a new and pointless set of operations (Incidentally, the old operation of left click – delete, to enter a word and change a character, not archives the email!).
In conclusion, I think MS should admit this was a mistake and put back the conventional controls. And probably re-assign those employees (or creche residents) responsible. Despite what many people think, I do no believe MS is in the business of deliberately annoying their customers.
Finally – when I tried to find out where to raise this as an issue / bug, I found there is not longer any online way to do this and there are only various software tools to try to fix issues yourself. Since this fits best into the category of feedback / bug repot, I really think MS should reinstate such online services.
Thanks,
T.
Hi, MS has changed mouse behavior in New Outlook. This seems an unusual move because PC users generally know how to use their keyboard and mouse – and have done for ~40 years. ctrl – left-click has, as long as I can remember, always enabled the user to select multiple items – text, files etc. But in New Outlook (not other MS programs) this has been disabled. This is a fundamental GUI operation. I can only imagine that the developer responsible has not been using PCs very much (or very long). Perhaps they are only accustomed to touch screens and / or are a very young child? The mouse behavior has also been changed for activating pop-up options, namely spell-check, which is now left-click (was right click). This means that roughly 2 billion users accustomed to spell checking / using pop-up edit menus now have the inconvenience of learning a new and pointless set of operations (Incidentally, the old operation of left click – delete, to enter a word and change a character, not archives the email!). In conclusion, I think MS should admit this was a mistake and put back the conventional controls. And probably re-assign those employees (or creche residents) responsible. Despite what many people think, I do no believe MS is in the business of deliberately annoying their customers. Finally – when I tried to find out where to raise this as an issue / bug, I found there is not longer any online way to do this and there are only various software tools to try to fix issues yourself. Since this fits best into the category of feedback / bug repot, I really think MS should reinstate such online services. Thanks, T. Read More
Microsoft Reporting Services – (localdb)MSSQLLocalDB
Using Reporting Services (project), I am able Create and Run reports. But I cannot deploy the project. (target report selected in properties)
I am hoping to deploy the report (report project) from my Startup project inside my projects Solution. However, when I deploy the project from Solution Explorer, it shows username and password dialog box, that I never entered during SQL installation setup. (does not work when entered)
So I tried to run reports using ReportViewer, which I know to run *.rdlc reports by default. Information that I read online says that ReportViewer will NOT run *.rdl files. However, I am okay with using ReportViewer with *.rdl reports, if possible.
All help and guidance appreciated in advance,
Shane.
Using Reporting Services (project), I am able Create and Run reports. But I cannot deploy the project. (target report selected in properties) I am hoping to deploy the report (report project) from my Startup project inside my projects Solution. However, when I deploy the project from Solution Explorer, it shows username and password dialog box, that I never entered during SQL installation setup. (does not work when entered) So I tried to run reports using ReportViewer, which I know to run *.rdlc reports by default. Information that I read online says that ReportViewer will NOT run *.rdl files. However, I am okay with using ReportViewer with *.rdl reports, if possible. All help and guidance appreciated in advance, Shane. Read More
(bug)MATLAB Support Package for Apple iOS Sensors could’t work?
When I install "MATLAB Support Package for Apple iOS Sensors" successfully,then input in command line:
m = mobiledev
Failure to load the device plug-in.
I have tried other similar commands such as "mobiledevlist", which gives the same error. I’m looking forward to the official fix to solve the problem in time!
MATLAB 2024a,windows 10 22H2When I install "MATLAB Support Package for Apple iOS Sensors" successfully,then input in command line:
m = mobiledev
Failure to load the device plug-in.
I have tried other similar commands such as "mobiledevlist", which gives the same error. I’m looking forward to the official fix to solve the problem in time!
MATLAB 2024a,windows 10 22H2 When I install "MATLAB Support Package for Apple iOS Sensors" successfully,then input in command line:
m = mobiledev
Failure to load the device plug-in.
I have tried other similar commands such as "mobiledevlist", which gives the same error. I’m looking forward to the official fix to solve the problem in time!
MATLAB 2024a,windows 10 22H2 matlab, matlab mobile, sensors MATLAB Answers — New Questions
MATLAB HiDPI setting ignored on Linux (Ubuntu)
Hi,
I am running a fresh install of MATLAB R2022b on Ubuntu 22.04.
Laptop: HP Zbook Fury G7 (screen resolution 3840×2160)
GPU1: Intel Cometlake-H GT2
GPU2: NVidia Quadro T1000.
MATLAB install script was executed as sudo, as described here (link [MATLAB]). There have been several related questions in MATLAB Answers (link1, link2, and many more related to Windows) but none seem to work for this case.
Few observations:
If xrandr is not used, the scaling setting is completely ignored.
Executing the xrandr with the calculated DPI, seems to affect only the splash screen, but not the MATLAB interface.
After xrandr, changing the scaling setting in MATLAB affects the editor only (without restart). This is behavior is again lost after restart.
Changing permission (as suggested by one comment) in the ~/.matlab file, did not work.
Installing MATLAB as non-sudo yields the same results.
Anyone knows if there is anything else I could try? Besides lowering the screen resolution, since that results in blurriness.
Thanks!
Edit 1: Typo
Edit 2: Looking around it seems to be a permission issue. For testing purposes only, I added ‘root’ user to the license and when changing the scaling setting it is honored as expected. In the ~/.matlab folder for the root user, the main differences is the presense of *.mlsettings binary files. Although, giving full persmissions to the $USER for both ~/.matlab as well as /usr/local/MATLAB folder does not seem to affect the process in any way.
Current workaround: copying matlab.mlsettings file from the root to the user’s .matlab directory seems fix the issue. But this is far from a solution. Modyfing any setting of these settings/preferences require to first run matlab as root, make the modifitiations and then copy-paste the relevant *.mlsettings files. Will update when I have more.
Edit 3: A better workaround (no root needed): It seems that if a desktop launcher is used (matlab-support package), bash is not run in advance and MATLAB does not access the system enviroment variables, including the TMPDIR/TMP. Then (for some reason..) MATLAB can not access the /tmp/ folder and this is probably where things break. Two ways go around this are:
Run matlab from terminal where bashrc is already sourced (including for example a TMP var to an accessible folder, e.g. ~/.tmp/).
Or, change the default MATLAB tempdir. This is inspired from the workaround of ‘Invalid cross-device link (18)’ error I also exprerienced when trying to save a document (link3). Although, this setting is again lost after a restart, at least for me.Hi,
I am running a fresh install of MATLAB R2022b on Ubuntu 22.04.
Laptop: HP Zbook Fury G7 (screen resolution 3840×2160)
GPU1: Intel Cometlake-H GT2
GPU2: NVidia Quadro T1000.
MATLAB install script was executed as sudo, as described here (link [MATLAB]). There have been several related questions in MATLAB Answers (link1, link2, and many more related to Windows) but none seem to work for this case.
Few observations:
If xrandr is not used, the scaling setting is completely ignored.
Executing the xrandr with the calculated DPI, seems to affect only the splash screen, but not the MATLAB interface.
After xrandr, changing the scaling setting in MATLAB affects the editor only (without restart). This is behavior is again lost after restart.
Changing permission (as suggested by one comment) in the ~/.matlab file, did not work.
Installing MATLAB as non-sudo yields the same results.
Anyone knows if there is anything else I could try? Besides lowering the screen resolution, since that results in blurriness.
Thanks!
Edit 1: Typo
Edit 2: Looking around it seems to be a permission issue. For testing purposes only, I added ‘root’ user to the license and when changing the scaling setting it is honored as expected. In the ~/.matlab folder for the root user, the main differences is the presense of *.mlsettings binary files. Although, giving full persmissions to the $USER for both ~/.matlab as well as /usr/local/MATLAB folder does not seem to affect the process in any way.
Current workaround: copying matlab.mlsettings file from the root to the user’s .matlab directory seems fix the issue. But this is far from a solution. Modyfing any setting of these settings/preferences require to first run matlab as root, make the modifitiations and then copy-paste the relevant *.mlsettings files. Will update when I have more.
Edit 3: A better workaround (no root needed): It seems that if a desktop launcher is used (matlab-support package), bash is not run in advance and MATLAB does not access the system enviroment variables, including the TMPDIR/TMP. Then (for some reason..) MATLAB can not access the /tmp/ folder and this is probably where things break. Two ways go around this are:
Run matlab from terminal where bashrc is already sourced (including for example a TMP var to an accessible folder, e.g. ~/.tmp/).
Or, change the default MATLAB tempdir. This is inspired from the workaround of ‘Invalid cross-device link (18)’ error I also exprerienced when trying to save a document (link3). Although, this setting is again lost after a restart, at least for me. Hi,
I am running a fresh install of MATLAB R2022b on Ubuntu 22.04.
Laptop: HP Zbook Fury G7 (screen resolution 3840×2160)
GPU1: Intel Cometlake-H GT2
GPU2: NVidia Quadro T1000.
MATLAB install script was executed as sudo, as described here (link [MATLAB]). There have been several related questions in MATLAB Answers (link1, link2, and many more related to Windows) but none seem to work for this case.
Few observations:
If xrandr is not used, the scaling setting is completely ignored.
Executing the xrandr with the calculated DPI, seems to affect only the splash screen, but not the MATLAB interface.
After xrandr, changing the scaling setting in MATLAB affects the editor only (without restart). This is behavior is again lost after restart.
Changing permission (as suggested by one comment) in the ~/.matlab file, did not work.
Installing MATLAB as non-sudo yields the same results.
Anyone knows if there is anything else I could try? Besides lowering the screen resolution, since that results in blurriness.
Thanks!
Edit 1: Typo
Edit 2: Looking around it seems to be a permission issue. For testing purposes only, I added ‘root’ user to the license and when changing the scaling setting it is honored as expected. In the ~/.matlab folder for the root user, the main differences is the presense of *.mlsettings binary files. Although, giving full persmissions to the $USER for both ~/.matlab as well as /usr/local/MATLAB folder does not seem to affect the process in any way.
Current workaround: copying matlab.mlsettings file from the root to the user’s .matlab directory seems fix the issue. But this is far from a solution. Modyfing any setting of these settings/preferences require to first run matlab as root, make the modifitiations and then copy-paste the relevant *.mlsettings files. Will update when I have more.
Edit 3: A better workaround (no root needed): It seems that if a desktop launcher is used (matlab-support package), bash is not run in advance and MATLAB does not access the system enviroment variables, including the TMPDIR/TMP. Then (for some reason..) MATLAB can not access the /tmp/ folder and this is probably where things break. Two ways go around this are:
Run matlab from terminal where bashrc is already sourced (including for example a TMP var to an accessible folder, e.g. ~/.tmp/).
Or, change the default MATLAB tempdir. This is inspired from the workaround of ‘Invalid cross-device link (18)’ error I also exprerienced when trying to save a document (link3). Although, this setting is again lost after a restart, at least for me. hidpi, linux, ubuntu MATLAB Answers — New Questions
What is wrong with my FFT code?
I have this code, the plot looks correct but the values don’t come out right. I even tested an ideal sine wave, but it’s the same. which means the code is wrong, but I can’t figure out which part of the code is wrong. it looks correct to me. please help me out;
% Parameters
N = 8192; % Number of samples for FFT
fs = 10e9; % Sampling frequency (10 GHz)
harmonics = 3; % Number of harmonics to consider
% Extract 8192 samples from OUTPUT (assuming OUTPUT is already defined)
x = OUTPUT(1:N);
% Normalize data to unit magnitude
x = x / max(abs(x));
% Perform FFT
X = fft(x);
% Frequency axis
f_axis = (0:N-1) * fs / N; % Frequency axis from 0 to fs
% Remove DC component
X(1) = 0;
% Find dominant frequency component
[~, max_idx] = max(abs(X)); % Find the index of the maximum magnitude
% Calculate estimated signal frequency
f_signal = f_axis(max_idx); % Frequency corresponding to the maximum magnitude
% Calculate SNR correctly
signal_power = abs(X(max_idx))^2; % Power of the signal tone
noise_power = sum(abs(X).^2) – signal_power; % Total noise power (excluding signal tone)
SNR = 10*log10(signal_power / noise_power); % Signal-to-Noise Ratio in dB
% Calculate ENOB
ENOB = (SNR – 1.76) / 6.02;
% Calculate SFDR
SFDR_power = max(abs(X))^2; % Power of the largest spurious component (excluding DC)
SFDR = 10*log10(SFDR_power / signal_power); % Spurious Free Dynamic Range in dB
% Calculate THD correctly
THD_power = sum(abs(X(2:end)).^2); % Total harmonic distortion power (excluding signal and DC)
THD = 10*log10(THD_power / signal_power); % Total harmonic distortion in dB
% Plot FFT magnitude spectrum (folded, centered around fs/2)
figure;
plot(f_axis / 1e6, 20*log10(abs(X) / N)); % Plot in MHz and dB
xlabel(‘Frequency (MHz)’);
ylabel(‘Magnitude (dB/Hz)’);
title(‘FFT Magnitude Spectrum’);
grid on;
xlim([0 fs/2/1e6]); % Limit x-axis to 0 to fs/2 in MHz
% Mark signal tone and harmonics on the plot
hold on;
plot(f_signal / 1e6, 20*log10(abs(X(max_idx)) / N), ‘ro’, ‘MarkerSize’, 10, ‘LineWidth’, 2); % Mark signal tone
for i = 1:harmonics
harmonic_freq = i * f_signal;
[~, harmonic_bin] = min(abs(f_axis – harmonic_freq)); % Find nearest bin index
plot(f_axis(harmonic_bin) / 1e6, 20*log10(abs(X(harmonic_bin)) / N), ‘go’, ‘MarkerSize’, 10, ‘LineWidth’, 2); % Mark harmonics
end
hold off;
% Create legend for ENOB, SNR, SFDR, THD without identifiers
legend_str = {[‘ENOB: ‘, num2str(ENOB), ‘ bits’], [‘SNR: ‘, num2str(SNR), ‘ dB’], …
[‘SFDR: ‘, num2str(SFDR), ‘ dB’], [‘THD: ‘, num2str(THD), ‘ dB’]};
legend(legend_str, ‘Location’, ‘best’, ‘AutoUpdate’, ‘off’); % AutoUpdate off to prevent adding previous legend entries
% Display results
disp([‘Estimated Signal Tone Frequency: ‘, num2str(f_signal / 1e6), ‘ MHz’]);
disp([‘ENOB: ‘, num2str(ENOB), ‘ bits’]);
disp([‘SNR: ‘, num2str(SNR), ‘ dB’]);
disp([‘SFDR: ‘, num2str(SFDR), ‘ dB’]);
disp([‘THD: ‘, num2str(THD), ‘ dB’]);I have this code, the plot looks correct but the values don’t come out right. I even tested an ideal sine wave, but it’s the same. which means the code is wrong, but I can’t figure out which part of the code is wrong. it looks correct to me. please help me out;
% Parameters
N = 8192; % Number of samples for FFT
fs = 10e9; % Sampling frequency (10 GHz)
harmonics = 3; % Number of harmonics to consider
% Extract 8192 samples from OUTPUT (assuming OUTPUT is already defined)
x = OUTPUT(1:N);
% Normalize data to unit magnitude
x = x / max(abs(x));
% Perform FFT
X = fft(x);
% Frequency axis
f_axis = (0:N-1) * fs / N; % Frequency axis from 0 to fs
% Remove DC component
X(1) = 0;
% Find dominant frequency component
[~, max_idx] = max(abs(X)); % Find the index of the maximum magnitude
% Calculate estimated signal frequency
f_signal = f_axis(max_idx); % Frequency corresponding to the maximum magnitude
% Calculate SNR correctly
signal_power = abs(X(max_idx))^2; % Power of the signal tone
noise_power = sum(abs(X).^2) – signal_power; % Total noise power (excluding signal tone)
SNR = 10*log10(signal_power / noise_power); % Signal-to-Noise Ratio in dB
% Calculate ENOB
ENOB = (SNR – 1.76) / 6.02;
% Calculate SFDR
SFDR_power = max(abs(X))^2; % Power of the largest spurious component (excluding DC)
SFDR = 10*log10(SFDR_power / signal_power); % Spurious Free Dynamic Range in dB
% Calculate THD correctly
THD_power = sum(abs(X(2:end)).^2); % Total harmonic distortion power (excluding signal and DC)
THD = 10*log10(THD_power / signal_power); % Total harmonic distortion in dB
% Plot FFT magnitude spectrum (folded, centered around fs/2)
figure;
plot(f_axis / 1e6, 20*log10(abs(X) / N)); % Plot in MHz and dB
xlabel(‘Frequency (MHz)’);
ylabel(‘Magnitude (dB/Hz)’);
title(‘FFT Magnitude Spectrum’);
grid on;
xlim([0 fs/2/1e6]); % Limit x-axis to 0 to fs/2 in MHz
% Mark signal tone and harmonics on the plot
hold on;
plot(f_signal / 1e6, 20*log10(abs(X(max_idx)) / N), ‘ro’, ‘MarkerSize’, 10, ‘LineWidth’, 2); % Mark signal tone
for i = 1:harmonics
harmonic_freq = i * f_signal;
[~, harmonic_bin] = min(abs(f_axis – harmonic_freq)); % Find nearest bin index
plot(f_axis(harmonic_bin) / 1e6, 20*log10(abs(X(harmonic_bin)) / N), ‘go’, ‘MarkerSize’, 10, ‘LineWidth’, 2); % Mark harmonics
end
hold off;
% Create legend for ENOB, SNR, SFDR, THD without identifiers
legend_str = {[‘ENOB: ‘, num2str(ENOB), ‘ bits’], [‘SNR: ‘, num2str(SNR), ‘ dB’], …
[‘SFDR: ‘, num2str(SFDR), ‘ dB’], [‘THD: ‘, num2str(THD), ‘ dB’]};
legend(legend_str, ‘Location’, ‘best’, ‘AutoUpdate’, ‘off’); % AutoUpdate off to prevent adding previous legend entries
% Display results
disp([‘Estimated Signal Tone Frequency: ‘, num2str(f_signal / 1e6), ‘ MHz’]);
disp([‘ENOB: ‘, num2str(ENOB), ‘ bits’]);
disp([‘SNR: ‘, num2str(SNR), ‘ dB’]);
disp([‘SFDR: ‘, num2str(SFDR), ‘ dB’]);
disp([‘THD: ‘, num2str(THD), ‘ dB’]); I have this code, the plot looks correct but the values don’t come out right. I even tested an ideal sine wave, but it’s the same. which means the code is wrong, but I can’t figure out which part of the code is wrong. it looks correct to me. please help me out;
% Parameters
N = 8192; % Number of samples for FFT
fs = 10e9; % Sampling frequency (10 GHz)
harmonics = 3; % Number of harmonics to consider
% Extract 8192 samples from OUTPUT (assuming OUTPUT is already defined)
x = OUTPUT(1:N);
% Normalize data to unit magnitude
x = x / max(abs(x));
% Perform FFT
X = fft(x);
% Frequency axis
f_axis = (0:N-1) * fs / N; % Frequency axis from 0 to fs
% Remove DC component
X(1) = 0;
% Find dominant frequency component
[~, max_idx] = max(abs(X)); % Find the index of the maximum magnitude
% Calculate estimated signal frequency
f_signal = f_axis(max_idx); % Frequency corresponding to the maximum magnitude
% Calculate SNR correctly
signal_power = abs(X(max_idx))^2; % Power of the signal tone
noise_power = sum(abs(X).^2) – signal_power; % Total noise power (excluding signal tone)
SNR = 10*log10(signal_power / noise_power); % Signal-to-Noise Ratio in dB
% Calculate ENOB
ENOB = (SNR – 1.76) / 6.02;
% Calculate SFDR
SFDR_power = max(abs(X))^2; % Power of the largest spurious component (excluding DC)
SFDR = 10*log10(SFDR_power / signal_power); % Spurious Free Dynamic Range in dB
% Calculate THD correctly
THD_power = sum(abs(X(2:end)).^2); % Total harmonic distortion power (excluding signal and DC)
THD = 10*log10(THD_power / signal_power); % Total harmonic distortion in dB
% Plot FFT magnitude spectrum (folded, centered around fs/2)
figure;
plot(f_axis / 1e6, 20*log10(abs(X) / N)); % Plot in MHz and dB
xlabel(‘Frequency (MHz)’);
ylabel(‘Magnitude (dB/Hz)’);
title(‘FFT Magnitude Spectrum’);
grid on;
xlim([0 fs/2/1e6]); % Limit x-axis to 0 to fs/2 in MHz
% Mark signal tone and harmonics on the plot
hold on;
plot(f_signal / 1e6, 20*log10(abs(X(max_idx)) / N), ‘ro’, ‘MarkerSize’, 10, ‘LineWidth’, 2); % Mark signal tone
for i = 1:harmonics
harmonic_freq = i * f_signal;
[~, harmonic_bin] = min(abs(f_axis – harmonic_freq)); % Find nearest bin index
plot(f_axis(harmonic_bin) / 1e6, 20*log10(abs(X(harmonic_bin)) / N), ‘go’, ‘MarkerSize’, 10, ‘LineWidth’, 2); % Mark harmonics
end
hold off;
% Create legend for ENOB, SNR, SFDR, THD without identifiers
legend_str = {[‘ENOB: ‘, num2str(ENOB), ‘ bits’], [‘SNR: ‘, num2str(SNR), ‘ dB’], …
[‘SFDR: ‘, num2str(SFDR), ‘ dB’], [‘THD: ‘, num2str(THD), ‘ dB’]};
legend(legend_str, ‘Location’, ‘best’, ‘AutoUpdate’, ‘off’); % AutoUpdate off to prevent adding previous legend entries
% Display results
disp([‘Estimated Signal Tone Frequency: ‘, num2str(f_signal / 1e6), ‘ MHz’]);
disp([‘ENOB: ‘, num2str(ENOB), ‘ bits’]);
disp([‘SNR: ‘, num2str(SNR), ‘ dB’]);
disp([‘SFDR: ‘, num2str(SFDR), ‘ dB’]);
disp([‘THD: ‘, num2str(THD), ‘ dB’]); fft code, adc, dsp, snr, enoub, sfdr, thd MATLAB Answers — New Questions
Why is str2num not recommended when it is faster in certain circumstances?
I have a cell array of millions of strings representing dates with the format "yyyyMMddHHmmss"
I need to convert these to datetimes. After many attempts of various kinds I think I have found an optimal solution.
However, my solution requires that I use str2num instead of str2double and results in nearly 100x increase in speed. This is depite the fact that MATLAB recommends using str2double for "faster performance" and specifically discourages str2num.
In particular, str2double cannot convert a char array and results in Inf, while str2num converts the char array without issue.
Below is an example script.
(P.S. not directly related to this question, but if there is a faster way to convert cell arrays of strings to datetimes, let me know!)
%Make example input data
t1 = datetime(2000,1,1,0,0,0);
t2 = datetime("now");
t = string(datestr(t1:days(1):t2,’yyyymmddHHMMss’));
t_cell = cellstr(t); %<— This is the "cell array" example data
%Option 1: datetime cell array of strings
% —> Very slow (~0.75 s)
tic
tcheck1 = datetime(t_cell,’InputFormat’,’yyyyMMddHHmmss’);
toc
%Option 2: str2double
% —> DOES NOT WORK (results in Inf)
tic
da = char(t_cell);
year1 = str2double(da(:,1:4));
month1 = str2double(da(:,5:6));
day1 = str2double(da(:,7:8));
hour1 = str2double(da(:,9:10));
min1 = str2double(da(:,11:12));
sec1 = str2double(da(:,13:14));
tcheck2 = datetime(year1,month1,day1,hour1,min1,sec1);
toc
%Option 3: str2double with extra conversion from char to string
% —> About twice as fast as Option #1 (~0.4 s)
tic
da = char(t_cell);
year1 = str2double(string(da(:,1:4)));
month1 = str2double(string(da(:,5:6)));
day1 = str2double(string(da(:,7:8)));
hour1 = str2double(string(da(:,9:10)));
min1 = str2double(string(da(:,11:12)));
sec1 = str2double(string(da(:,13:14)));
tcheck3 = datetime(year1,month1,day1,hour1,min1,sec1);
toc
%Option 3: str2num
% —> About 100 times faster than Option #1 and #3 (~0.005 s)
tic
da = char(t_cell);
year1 = str2num(da(:,1:4));
month1 = str2num(da(:,5:6));
day1 = str2num(da(:,7:8));
hour1 = str2num(da(:,9:10));
min1 = str2num(da(:,11:12));
sec1 = str2num(da(:,13:14));
tcheck4 = datetime(year1,month1,day1,hour1,min1,sec1);
tocI have a cell array of millions of strings representing dates with the format "yyyyMMddHHmmss"
I need to convert these to datetimes. After many attempts of various kinds I think I have found an optimal solution.
However, my solution requires that I use str2num instead of str2double and results in nearly 100x increase in speed. This is depite the fact that MATLAB recommends using str2double for "faster performance" and specifically discourages str2num.
In particular, str2double cannot convert a char array and results in Inf, while str2num converts the char array without issue.
Below is an example script.
(P.S. not directly related to this question, but if there is a faster way to convert cell arrays of strings to datetimes, let me know!)
%Make example input data
t1 = datetime(2000,1,1,0,0,0);
t2 = datetime("now");
t = string(datestr(t1:days(1):t2,’yyyymmddHHMMss’));
t_cell = cellstr(t); %<— This is the "cell array" example data
%Option 1: datetime cell array of strings
% —> Very slow (~0.75 s)
tic
tcheck1 = datetime(t_cell,’InputFormat’,’yyyyMMddHHmmss’);
toc
%Option 2: str2double
% —> DOES NOT WORK (results in Inf)
tic
da = char(t_cell);
year1 = str2double(da(:,1:4));
month1 = str2double(da(:,5:6));
day1 = str2double(da(:,7:8));
hour1 = str2double(da(:,9:10));
min1 = str2double(da(:,11:12));
sec1 = str2double(da(:,13:14));
tcheck2 = datetime(year1,month1,day1,hour1,min1,sec1);
toc
%Option 3: str2double with extra conversion from char to string
% —> About twice as fast as Option #1 (~0.4 s)
tic
da = char(t_cell);
year1 = str2double(string(da(:,1:4)));
month1 = str2double(string(da(:,5:6)));
day1 = str2double(string(da(:,7:8)));
hour1 = str2double(string(da(:,9:10)));
min1 = str2double(string(da(:,11:12)));
sec1 = str2double(string(da(:,13:14)));
tcheck3 = datetime(year1,month1,day1,hour1,min1,sec1);
toc
%Option 3: str2num
% —> About 100 times faster than Option #1 and #3 (~0.005 s)
tic
da = char(t_cell);
year1 = str2num(da(:,1:4));
month1 = str2num(da(:,5:6));
day1 = str2num(da(:,7:8));
hour1 = str2num(da(:,9:10));
min1 = str2num(da(:,11:12));
sec1 = str2num(da(:,13:14));
tcheck4 = datetime(year1,month1,day1,hour1,min1,sec1);
toc I have a cell array of millions of strings representing dates with the format "yyyyMMddHHmmss"
I need to convert these to datetimes. After many attempts of various kinds I think I have found an optimal solution.
However, my solution requires that I use str2num instead of str2double and results in nearly 100x increase in speed. This is depite the fact that MATLAB recommends using str2double for "faster performance" and specifically discourages str2num.
In particular, str2double cannot convert a char array and results in Inf, while str2num converts the char array without issue.
Below is an example script.
(P.S. not directly related to this question, but if there is a faster way to convert cell arrays of strings to datetimes, let me know!)
%Make example input data
t1 = datetime(2000,1,1,0,0,0);
t2 = datetime("now");
t = string(datestr(t1:days(1):t2,’yyyymmddHHMMss’));
t_cell = cellstr(t); %<— This is the "cell array" example data
%Option 1: datetime cell array of strings
% —> Very slow (~0.75 s)
tic
tcheck1 = datetime(t_cell,’InputFormat’,’yyyyMMddHHmmss’);
toc
%Option 2: str2double
% —> DOES NOT WORK (results in Inf)
tic
da = char(t_cell);
year1 = str2double(da(:,1:4));
month1 = str2double(da(:,5:6));
day1 = str2double(da(:,7:8));
hour1 = str2double(da(:,9:10));
min1 = str2double(da(:,11:12));
sec1 = str2double(da(:,13:14));
tcheck2 = datetime(year1,month1,day1,hour1,min1,sec1);
toc
%Option 3: str2double with extra conversion from char to string
% —> About twice as fast as Option #1 (~0.4 s)
tic
da = char(t_cell);
year1 = str2double(string(da(:,1:4)));
month1 = str2double(string(da(:,5:6)));
day1 = str2double(string(da(:,7:8)));
hour1 = str2double(string(da(:,9:10)));
min1 = str2double(string(da(:,11:12)));
sec1 = str2double(string(da(:,13:14)));
tcheck3 = datetime(year1,month1,day1,hour1,min1,sec1);
toc
%Option 3: str2num
% —> About 100 times faster than Option #1 and #3 (~0.005 s)
tic
da = char(t_cell);
year1 = str2num(da(:,1:4));
month1 = str2num(da(:,5:6));
day1 = str2num(da(:,7:8));
hour1 = str2num(da(:,9:10));
min1 = str2num(da(:,11:12));
sec1 = str2num(da(:,13:14));
tcheck4 = datetime(year1,month1,day1,hour1,min1,sec1);
toc datetime, string, double, convert MATLAB Answers — New Questions