Answered
how to access images from sub folders?
Using |dir|: D = 'path to directory F1'; S = dir(fullfile(D,'S*')); for ii = 1:numel(S) E = dir(fullfile(D,S(i...

8 years ago | 1

| accepted

Answered
finding row number of an array elements in related columns of a matrix
This is simple with the second output of <https://www.mathworks.com/help/matlab/ref/max.html |max|>: >> A = [5,4,1,4;1,2,4,...

8 years ago | 1

| accepted

Answered
I keep getting 'Undefined function or variable 't' ' after running the code
You do not explain how you are calling the function, but that is likely to be the problem. Perhaps you are trying to call it by ...

8 years ago | 0

Answered
trying to create a loop for for opening data files and plotting them
_"I want to change it so that a different file is opened with each loop but i'm not sure how"_ By following the guidelines in...

8 years ago | 0

| accepted

Answered
How to restore output of for loop in matrix
mat = zeros(10,2); for ii = 1:10 for jj = 1:2 mat(ii,jj) = sum((sam(ii,:)-cen(jj,:)).^2); end e...

8 years ago | 0

| accepted

Answered
Invisible graphics objects are selectable
You could use <https://www.mathworks.com/help/matlab/ref/uistack.html |uistack|> to move the legend behind everything else, and ...

8 years ago | 0

| accepted

Answered
Please help me in debugging my code?
The bug is on these lines: if (first_function(x_mid))*(first_function(x_lower))<0 x_lower = x_mid; else x...

8 years ago | 0

| accepted

Answered
writing multiple variables with eval into excel spreadsheet
_"But I had no idea how to export nicely..."_ You can't. Doing anything _"nicely"_ is impossible with that code. Becaus...

8 years ago | 0

| accepted

Answered
how to import an audio file ?
Use <https://www.mathworks.com/help/matlab/ref/audioread.html |audioread|>. Why do you think that your code is not working? What...

8 years ago | 0

| accepted

Answered
Multiplication of two matrices of different rank
_" I can come up with a tentative way that is to reshape ... and do the multiplication and reshape it back"_ That seems like ...

8 years ago | 0

Answered
How to create a set subsets?
Use a <https://www.mathworks.com/help/matlab/cell-arrays.html cell array>: S = {[1,4,7],[1,4],[4,5,7],[3,5,6],[2,3,6,7],[2,...

8 years ago | 1

| accepted

Answered
Saving output of for loop in array
Pload = linspace(1,2,4); N = numel(Pload); P = repmat(Pload,10,1); for k = 1:10 P(k,:) = P(k,randperm(N)); ...

8 years ago | 0

Answered
How do I call on a function created outside of the App Editor?
_"How do I actually point the App to the script located on my computer?"_ Simple, just change the MATLAB Search Path., becaus...

8 years ago | 0

Answered
I have to switch the max and min elements in a vector and assume vec = ceil(rand(1, 10)*100) is a vector containing 10 random generated integers. The script i have to provide will swap the maximum and the minimum element in the vector.
Even though this is homework without any attempt... here is a neat and efficient MATLAB way to do that (this swaps the first min...

8 years ago | 0

Answered
Splitting a column (and a numerical value in that column) into multiple columns
Divide, then use <https://www.mathworks.com/help/matlab/ref/mat2cell.html |mat2cell|>

8 years ago | 0

| accepted

Answered
how to filter column from a text file
fmt = '%-6d %.3f %.4f %.4f %.3f\n'; mat = dlmread('test_old.txt'); [fid,msg] = fopen('test_new.txt','wt'); assert...

8 years ago | 0

| accepted

Answered
how to convert data which is saved as cell should be converted into double type how to do it?
An explicit loop is not required to use |fileparts| with a cell array: [P,N] = cellfun(@fileparts,Imagename,'uni',0) But...

8 years ago | 0

Answered
Is the "smooth" function no longer supported in 2018b?
<https://www.mathworks.com/help/curvefit/smooth.html |smooth|> is in the Curve Fitting Toolbox. Do you have the Curve Fitting...

8 years ago | 1

| accepted

Answered
Finding and setting new values for matrix elements within a cell array
The simplest and most efficient solution is to use a |for| loop. But then you write _"...there are also several cases in my d...

8 years ago | 0

Answered
Inserting another column into an existing table
I am guessing that you want that data in columns, something like this: TF = 40:-10:-40; Vmph = 10:10:60; Twc = rou...

8 years ago | 0

Answered
File names in plots legend, from struct data; Matlab says is not an array.
Probably |leg| is not a cell array, so trying to use cell array indexing with it is going to be an error. Solution: make |leg...

8 years ago | 0

| accepted

Answered
Changing letters to other letters with regexprep
You don't need <https://www.mathworks.com/help/matlab/ref/regexprep.html |regexprep|>, using <https://www.mathworks.com/help/mat...

8 years ago | 1

| accepted

Answered
Keep getting error message for making a script for checking the value of a number between 100&200?
*Explanation*: that bug is very simple: you named a variable |input|, which shadows the inbuilt |input| function. The very fi...

8 years ago | 0

| accepted

Answered
Convert cell array of character vectors to evaluable expressions
This is pretty easy with standard string parsing tools, e.g. <https://www.mathworks.com/help/matlab/ref/sscanf.html |sscanf|>: ...

8 years ago | 0

| accepted

Answered
write in txt file staring from the last line
<https://www.mathworks.com/help/matlab/ref/fopen.html |fopen|> the file using the append option |'a'|.

8 years ago | 1

Answered
How i can insert 'L' number of zeros after each element in a vector
>> x = [1,2,3,4]; >> L = 3; >> y = reshape([x;zeros(L,numel(x))],1,[]) y = 1 0 0 0 2 0 0 0 3 ...

8 years ago | 2

| accepted

Answered
Writing array data to file
If |tension| and |epsilon| are non-scalar and are intended to be printed as columns then your code will not work. Text files are...

8 years ago | 1

| accepted

Answered
Plot bar chart from elements of string
>> [U,~,X] = unique(thecountry); >> cnt = histc(X,1:numel(U)); >> bar(cnt) creates this: <</matlabcentral/answers/...

8 years ago | 0

| accepted

Answered
Textscan MULTIPLE DELIM ARRAY and rearrange
This automatically adjusts to the size of the input data. You could easily adapt it to work with either <https://www.mathworks.c...

8 years ago | 1

Load more