MATLAB GUI: Different results when opening a figure file using GUIDE and straightaway - matlab

I have made a MATLAB GUI but I am facing a problem. The problem is that when I open the GUI figure file straightaway, the resulting GUI does not work properly(I am guessing there is a problem with the loading of the opening_function). But when I open that figure file using GUIDE, I am getting proper results. I want the GUI figure to run properly when I click on it. I have provided the link for my GUI figure file and the M-file for the same in the below link using Google drive:
Google drive link for GUI figure file and code file (along with an image required for the working of the two)

your google drive link is not working. also if its your account of google drive which you have used to login then i can't access the files in it...use some other file hosting services to share the screenshot.
also you can always debug your callback functions using breakpoints to check why its not working properly.

Related

Can I upload a file to onedrive via Windows 10 command line?

I need to upload a file to OneDrive, via the command line. This will be done through a batch file which is distributed to end users.
From searching on Stack Overflow, I find questions like this one which say that you need to register an app and create an app password, using Azure. I don't have the necessary permissions to do this in the organization where I work, nor can I do anything that requires an admin account. So I can't any install software - I have to use what comes with Windows 10. I can't use VBA either as that's blocked.
I've managed to download files from OneDrive without anything like that, using the process described here:
Open the URL in either of the browser.
Open Developer options using Ctrl+Shift+I.
Go to Network tab.
Now click on download. Saving file isn’t required. We only need the network activity while browser requests the file from the server.
A new entry will appear which would look like “download.aspx?…”.
Right click on that and Copy → Copy as cURL.
Paste the copied content directly in the terminal and append ‘--output file.extension’ to save the content in file.extension since
terminal isn’t capable of showing binary data.
Example:
curl https://xyz.sharepoint.com/personal/someting/_layouts/15/download.aspx?UniqueId=cefb6082%2D696e%2D4f23%2D8c7a%2
…. some long text ….
cCtHR3NuTy82bWFtN1JBRXNlV2ZmekZOdWp3cFRsNTdJdjE2c2syZmxQamhGWnMwdkFBeXZlNWx2UkxDTkJic2hycGNGazVSTnJGUnY1Y1d0WjF5SDJMWHBqTjRmcUNUUWJxVnZYb1JjRG1WbEtjK0VIVWx2clBDQWNyZldid1R3PT08L1NQPg==;
cucg=1’ --compressed --output file.extension
I tried to do something similar after clicking 'upload' on the browser, but didn't find anything useful when trying to filter the requests.
I found these two questions but there is no keyboard shortcut to upload, AFAICT. Also the end user will be uploading a file to a folder I've shared with them from my OneDrive. Opening Chrome or Edge as a minimised window is fine, but I can't just shove a window in their face which automatically clicks on things - they won't like that.
It's just occurred to me that I might be able to use an office application to Save As the file to the necessary onedrive folder, where the keyboard shortcuts are pretty stable, but have no idea how to achieve that via the command line.
The best and more secure way to accomplish this goal I think is going to be with the Rest API for OneDrive.
(Small Files <4MB)
https://learn.microsoft.com/en-us/onedrive/developer/rest-api/api/driveitem_put_content?view=odsp-graph-online
(Large files)
https://learn.microsoft.com/en-us/onedrive/developer/rest-api/api/driveitem_createuploadsession?view=odsp-graph-online
You still need a Azure AD App Registration (which your admin should be able to configure for you), to provide API access to services in Azure. Coding with the API is going to be far easier and less complicated, not to mention more versatile.

Downloading files from IE11 using Powershell

I'm currently trying to work on a method of downloading files from a website using PowerShell v2. So far I can navigate to the appropriate page and click the link to download, however, when I do this the download banner appears at the bottom of the page asking me whether I'd like to open or save the file.
Does anyone know how to reference this banner in PowerShell (or even if it's possible), or failing that perhaps a method of turning off the alerts and saving as default?
Here's an example of a download banner from IE11 that I mention above.
Thanks,

Automatically respond to Matlab uigetfile

Is it possible to script a response to Matlab's uigetfile?
For example, I have a script saved as p code (uneditable) that contains calls to uigetfile. Normally, a user would run the script and manually select a file using the file browser created by uigetfile. If a user wanted to run the script on a thousand input files, the user would have to manually select every file using the file browser.
So, is there a way to run the pcode from another script and automatically respond to uigetfile's file browser. I realize that the best solution would be to do away with uigetfile, but that is not feasible in this situation.
If you are calling uigetfile in a p-file, unfortunately there is nothing you can do with Matlab.
You can have a look at Sikuli, though. It is a graphical automating software, which can handle the uigetfile popups for you.

Error in opening a video in Matlab

I need help in Matlab 2012a, due to its my first time using it.
When i write the function to open a video "mmread ('jp.avi')" in matlab an error pops up as it is shown below :
Error using FFGrab
Unable to open file
Error in mmread (line 146)
FFGrab('build',filename,fmt,double(disableVideo),double(disableAudio),double(trySeeking));
Note :I put this avi video in the mmread folder.
I searched in the internet regarding this issue but unfortunately I didn't get any results.
If you have any solution that may work, please let me know.
The error means MATLAB can't find the file. You should not put stuff in folders owned by MATLAB. Instead, put it in a folder whose location you know, and navigate to it in the 'Current Folder' panel (usually on the left) when you start your MATLAB session (or by using the Current Folder dropdown at the top, or by using the cd command). Then it will be available for your use without a fully qualified path.
Additionally, I don't think you're supposed to use mmread directly; you should use the VideoReader class instead; there is an example of its use at the bottom of the linked documentation page.

Getting Data from website

So the website constantly changes the data that it displays, and I want to get that data every several seconds and log it in a spreadsheet. The problem is in order to get to the page, I have to have a cookie which I get when I log in. Unfortunately I only know how to program in MATLAB. MATLAB has a function for this, urlread, but it doesn't deal with cookies. What can I do to get to that page? Can anyone help me with this? Point me into a direction where a programing noob like me can succeed please.
You could use wget to download content while using HTTP cookies. I will be using StackOverflow.com as example target. Here are the steps to follow:
1) Obtain the wget command tool. For Mac or Linux, I think it is already available. On Windows, you can get it from the GnuWin32 project or from one of the many other ports (Cygwin, MinGW/MSYS, etc..).
2) Next we need to obtain an authenticated cookie by logging into the website in question. You can use your preferred browser for this.
In Internet Explorer, you can produce it using "File menu > Import and Export > Export Cookies". In Firefox, I used the Cookie Exporter extension to export cookies to text file. For Chrome, there should be similar extensions
Obviously you only need to do this step once, as long as the cookies have not yet expired!
3) Once you locate the cookie file exported, we can use wget to fetch the web page and provide it with this cookie. This of course can be performed from inside MATLAB using the SYSTEM function:
%# fetch page and save it to disk
url = 'http://stackoverflow.com/';
cmd = ['wget --cookies=on --load-cookies=./cookies.txt ' url];
system(cmd, '-echo');
%# process page: I am simply viewing it using embedded browser
web( ['file:///' strrep(fullfile(pwd,'index.html'),'\','/')] )
Parsing the web page is a whole other topic that I will not go into. Once you get the data you seek, you can interact with Excel spreadsheets using the XLSREAD and XLSWRITE functions.
4) Finally you can write this in a function, and make it execute on regular intervals using the TIMER function
Try using the java.net.* classes.
You should be able to use them directly in the MATLAB workspace, as described here: http://www.mathworks.co.uk/help/techdoc/matlab_external/f4863.html
Matlab has built-in functions for web downloading. For http sites, there is webread.m and websave.m. For FTPs, there is mget.m