Recently I got a bunch of files that have the same format and structure and I need to use Matlab to process each file, which means carrying out the same calculation procedure to each file. Here's the code I created to do this.
% Import the file names
% The {*.csv} parameter indicates that only csv files will be shown in the file selection window
% Turn on the MultiSelect parameter so that multiple files can be selected at the same time
[filename, ~,~]=uigetfile({*.csv}, 'MultiSelect', 'on');
% now use a for loop to carry out same calculation procedure to each file
% the process_each_file is a function that does the calculation procedure
% before using the for loop, let's define a space to store all the outputs from each file calculation first
Re=zeros(length(filename),1);
for i = 1 : length(filename)
Re(i)=process_each_file ( filename(i))
end
MATLAB applications, tutorials, examples, tricks, resources,...and a little bit of everything I learned ...
Subscribe to:
Post Comments (Atom)
my-alpine and docker-compose.yml
``` version: '1' services: man: build: . image: my-alpine:latest ``` Dockerfile: ``` FROM alpine:latest ENV PYTH...
-
It took me a while to figure out how to insert a space in Mathtype equations. This is especially useful when you write an equation with mult...
-
Recently I read post from Dr. Doug Hull's blog: http://blogs.mathworks.com/videos/2009/10/23/basics-volume-visualization-19-defining-s...
-
To get the slope of a pair of x and y, usually I first plot the curve and then add the trend line. Actually there are two functions i...
This comment has been removed by the author.
ReplyDeletehello!
ReplyDeleteFirst of all I would like to thank you and say congratulations because your blog is awesome and has help me so much.
I am a student dealing with MatLab and want to do something like you are doing in this article.
Hope you can help because I think I must be mistaken in something without importance but I can not overcome this step and is really pissing me off!
Let me explain you:
I have created a GUI with a first button with the uigetfile to get DICOM files; in order to make a handle I can work with in other buttons.
I have tried the commands you put here and in the process_each_file function make a dicomread and a handle, but it gives me error "too many output arguments".
If I write the function like this:
function [Fname] = process_each_file(Fname)
I get:
The following error occurred converting from cell to double:
Error using double
Conversion to double from cell is not possible.
Hope you could help me; what I'm trying to do is get more than one dicom file with uiget and multiselect on, then use dicomread and make handles to use in other buttons.
Thank you so much for your time and work these years, your trick and tutorials are just great, we talk to them a lot in the university.
Best regards,
José Luis
Hi Jose,
DeleteI don't totally get your questions, but here are my 2 cents about the error message you got.
For the first one, 'too many output arguments' is a pretty straightforward one. You just used too many output arguments. You can define more output in the function to fix this issue.
For the second one, you need to look into the matlab data type and how to convert them. This link should be helpful:
http://www.mathworks.com/help/matlab/data-type-conversion.html
Good luck!