Answered
Flip matrix by every nth row
This is MATLAB, so just generate the indices: idx = reshape(flipud(reshape(1:121,11,11)),1,121); mat(idx,:) These indic...

9 years ago | 1

| accepted

Answered
How do I combine multiple MAT files into a single matrix
Easy: |load| into a variable (which is a structure): S = load(...); Do this in a loop, and construct a <https://www.math...

9 years ago | 0

Answered
Access variables in several .mat files
Here is a simpler, faster method, without using slow and buggy |eval|: files = {'file1.mat', 'file2.mat', 'file3.mat', 'fil...

9 years ago | 0

| accepted

Answered
Can Matlab make calculation errors?
Your code has many obvious bugs or "features" in it: # You define the |fprintf| format with |%s| instead of some numeric form...

9 years ago | 1

| accepted

Answered
How to read data from different text file in a loop, save in a matrix and plot??
If you want to import the files in alphanumeric order than you could download my FEX submission natsortfiles, and use the exampl...

9 years ago | 0

Answered
How to sort large data from a cell array
You could use <https://www.mathworks.com/help/matlab/ref/mat2cell.html |mat2cell|>: C = squeeze(mat2cell(D,1,10,6*ones(1,14)...

9 years ago | 0

Answered
How to find columns by name in a cell aray
This is easy with |strncmp|: >> inp = {'A_F1','B_F2','A_F2','G_F5';1,2,3,4}; % demo matrix. >> idx = strncmp(inp(1,:),'A...

9 years ago | 0

| accepted

Answered
Use the index in a FOR loop for a string
@Mamali: you should put your data into *one* array (either an matrix, and ND array, or a cell array) and using indexing. Do not ...

9 years ago | 0

| accepted

Answered
Textscan loop to store multiple groups of data
opt = {'Delimiter',','}; fmt = '%f%f'; out = {}; [fid,msg] = fopen('test.txt','rt'); assert(fid>=3,msg) while ~...

9 years ago | 0

Answered
Is it possible to loop a textscan?
Here is an alternative to a loop. This code specifies the |*| character to be the newline and calls |textscan| just once to read...

9 years ago | 0

Answered
Plot a graph that interpolates between NaNs?
So remove the NaNs: id1 = ~isnan(y1); id2 = ~isnan(y2); plotyy(x1(id1),y1(id1),x2(id2),y2(id2))

9 years ago | 0

| accepted

Answered
adding a matrix layer to an already existing matrix
M(:,:,2) = bsxfun(@plus,-89:90,(-89:90).');

9 years ago | 0

| accepted

Answered
compile script to create program
function myfun(filename) % delimiter = ','; startRow = 2; ... the rest of your code. end And then call it us...

9 years ago | 0

Answered
What is wrong with my code when it has no errors but does nothing when i try to run it?
Why does it not work? Because no files are found. Why are no files found? Because you concatenate using |strcat| instead of <...

9 years ago | 1

| accepted

Answered
how to transfer a cell array content into ordinal values?
This is easy with <https://www.mathworks.com/help/matlab/ref/regexp.html |regexp|> in just four lines, no loops or ifs or switch...

9 years ago | 2

Answered
Got couple of questions from college assignments
doc find

9 years ago | 0

| accepted

Answered
How do I initialize a variable that depends on the default button in a radio button group? I can't wait for user to select a different button.
One simple solution is to call the callbacks at the end of creating the figure/GUI. Have a look at my FEX submission <https:/...

9 years ago | 0

Answered
Need help with creating 500 column vector
The assignment does not ask for 500 columns, but one column with 500 elements: _"500-element column vector"_. P17M11 = vertc...

9 years ago | 0

| accepted

Answered
How to create cell array with a function?
A more efficient concept would use something like |textscan|: function C = myfun(file) opt = {'CollectOutput',true}; fmt...

9 years ago | 0

Answered
How can i round numbers to multiple of any number?
>> V = [9,13,18,25,34]; >> N = 8; >> N*floor(V/N) ans = 8 8 16 24 32

9 years ago | 9

| accepted

Answered
Hi, I'm having trouble getting my script to prompt the user to re-enter the input if it isn't a number. I've seen a few similar questions but none seem to work for me.
Always use the |'s'| option with |input|, even when you want a numeric value, e.g.: gallons = str2double(input('Please enter...

9 years ago | 0

Answered
Hey guys, I am really lost and I don't know where to start with this question
This code does the job (copied from my answer to <https://www.mathworks.com/matlabcentral/answers/315751-how-to-request-addition...

9 years ago | 0

| accepted

Answered
how to read multiple images from a folder
Something like this should get you started (obviously untested): D = 'directory path here'; S = dir(fullfile(D,'*.tif'))...

9 years ago | 1

Answered
How can i extrapolate a logspaced vector without changing my old vector?
I used 8 samples to make the values easier to understand: >> V = logspace(log10(0.003),log10(0.25),8); % data vector V =...

9 years ago | 1

| accepted

Answered
how to remove comma from certain items only from cell array with several items
This is easy with <https://www.mathworks.com/help/matlab/ref/regexprep.html |regexprep|>: >> str = {'"98,786","103,630","95...

9 years ago | 3

| accepted

Answered
how can i display color name of any given image using image processing?
You can download my FEX submission, which identifies colornames matching the input RGB values: <https://www.mathworks.com/mat...

9 years ago | 1

| accepted

Answered
Error iterating with fractions
Fractions cannot be used as indices. Put the fractional values in a vector and make the indices integers: vec = 1.1:0.1:roun...

9 years ago | 0

| accepted

Answered
Reading within parentheses in MATLAB
This is very easy with <http://www.mathworks.com/help/matlab/ref/regexp.html |regexp|>: >> C = {'401 (106)', '234 (113)', '...

9 years ago | 1

Answered
Automatically change header name
>> fmt = ['x',sprintf('\\tz%d',1:10),'\n'] fmt = x\tz1\tz2\tz3\tz4\tz5\tz6\tz7\tz8\tz9\tz10\n Also note that you should ...

9 years ago | 0

| accepted

Answered
Hi. I have 11 images in a folder and I want to read and display them. I tried few of ur codes bt the images displayed are nt sorted. plz help me
Taking a guess that the order should be alphanumeric, in which case you could download my FEX submission natsortfiles which sort...

9 years ago | 0

Load more