Answered
How can I save multiple plots to separate image files with variable file name?
_"...if I create a plot of intensity for every row of pixels and save evey plot to separate image files, I have to use variables...

8 years ago | 0

| accepted

Answered
How to use for loop to read one file in multiple folders?
This should get you started: D = 'directory where the subfolders are stored'; C = cell(1,365); for k = 1:365 ...

8 years ago | 0

Answered
i want to write matlab code for x(i+1) = x(i) + 0.05*2*x(i), i=0:0.05:1, x(0) =2
Perhaps one of these does what you want: >> i = 0:0.05:1; >> x = cumsum(2+0.05*2*i) x = 2.0000 4.0050 6.01...

8 years ago | 0

Answered
How to I add loop vector iteration values to one big matrix?
Assuming that |myfun| outputs a 5-element vector, just use indexing like this: phi = 0.5:0.2:1.5; mat = nan(5,numel(phi)...

8 years ago | 0

| accepted

Answered
Matrix dimensions must agree. Error while using if.
Use <https://www.mathworks.com/help/matlab/ref/strcmp.html |strcmp|> or <https://www.mathworks.com/help/matlab/ref/strcmpi.html ...

8 years ago | 2

Answered
3D image stack; determine mean of individual arrays; error code
squeeze(mean(mean(Array,1),2))

8 years ago | 0

Answered
How can I display the answer of every iteration in a "for" loop?
_"How can I display the answer of every iteration in a "for" loop?"_ _"Whenever I run the program I only get the final value ...

8 years ago | 0

| accepted

Answered
Is there a way to execute multiple functions in Matlab at a specific time ???
<https://www.mathworks.com/help/matlab/matlab_prog/use-a-matlab-timer-object.html> For example, for your first function: ...

8 years ago | 1

| accepted

Answered
Creating Loop using vector output
The problem has nothing to do with loops, it occurs solely because you are trying to allocate multiple elements into one element...

8 years ago | 0

Answered
Cell array of coordinates from two vectors
No loops required, just use <https://www.mathworks.com/help/matlab/ref/ndgrid.html |ndgrid|> and indexing: >> X = randi(999...

8 years ago | 0

| accepted

Answered
Am I doing something wrong in cody submission?
Your function returns |y|, which is just the index from |sort| and has nothing to do with the first column of |x|. The code |...

8 years ago | 3

| accepted

Answered
What does tmp(k, n) command mean in matlab?
MATLAB does not require variables to be declared before being indexed into: when they are first referred to the variable will be...

8 years ago | 0

Answered
How to restructure/reshape matrix?
This is easy with <https://www.mathworks.com/help/matlab/ref/hankel.html |hankel|>, some indexing, and <https://www.mathworks.co...

8 years ago | 0

Answered
Change if -statement by userinput
*Method one:* use a cell array of function handles, and simply use the index from the menu to select which one you want: id...

8 years ago | 0

| accepted

Answered
How to set Variable-step in ODE15s?
_"Yes, the two curves look the same_" Because they are the same, within the precision of the solver and for the steps that yo...

8 years ago | 1

| accepted

Answered
Opening folders and read its information
This should get you started: D = 'C:\Deterministic\New Objectives'; S = dir(fullfile(D,'Normal_4000*')); N = {S([S.is...

8 years ago | 0

| accepted

Answered
How to create a surface plot from three variables?
If you cannot use |meshgrid| and do not have gridded data, then the easiest solution is to create three vectors (X, Y, Z), creat...

8 years ago | 1

Answered
How to use imshow with a structure ?
S = getframe(...) imshow(S.cdata) % for TrueColor image (RGB). imshow(S.cdata, S.colormap) % for indexed image.

8 years ago | 0

| accepted

Answered
remove a struct field that its element value is less than specific 50
If you want to remove elements of the structure use logical indexing: Faces = cellfun('length', {CClower.faces}); CClowe...

8 years ago | 0

Answered
Inverse of sorting arrangement
Assuming that A is a vector: [B,I] = sort(A); [~,J] = sort(I); B(J) If you have a matrix/array, then you first need to defin...

8 years ago | 4

| accepted

Answered
How to write a .txt file in this way?
Writing that file is easy and efficient with one loop: C = {'pre','post','shift'}; [fid,msg] = fopen('test.txt','wt'); ...

8 years ago | 1

| accepted

Answered
how to select values of nx3 matrix where its index is equal to a value in other matrix
_"how to select values of nx3 matrix where its index is equal to a value in other matrix"_ As far as I can tell, you can do t...

8 years ago | 0

Answered
Matlab equality problem. Please help.
You have to learn about floating point numbers, and why you should not test them for equality like that. Always compare the abso...

8 years ago | 0

| accepted

Answered
How does logical indexing work ?
v = v1(v1 > 6) _"stores in v the elements of v1 that are greater than 6."_ Yes. Because that comparison returns a _logic...

8 years ago | 2

| accepted

Answered
changing dimension in a loop
There is a neat trick for that: simply put the indices into a cell array, which you can then redefine using indexing. S = n...

8 years ago | 1

| accepted

Answered
use of variables in cellst and num2cell
Copied from the MATLAB documentation: <https://www.mathworks.com/help/matlab/import_export/process-a-sequence-of-files.html> ...

8 years ago | 1

Answered
I have an input array 'z' with which I want to create an array 'p' in the way given below. The length and values of 'z' is varying. How I can register 'p' for every case of 'z'. Thank you
>> z = [-0.5,-0.25,0,0.25,0.5]; In two lines using |repmat|: >> p = repmat(z,2,1); >> p = p(2:end-1) p = -0...

8 years ago | 0

| accepted

Answered
Accessing all lower elements of a structure
_"so I expected similar functionality for a structure."_ There are easy ways to access structures, but not with the kind of "...

8 years ago | 0

| accepted

Answered
How to reshape array items and put them in a single cell
Where |M| is your 360x1280 matrix: C = squeeze(num2cell(reshape(M.',10,128,360),1:2));

8 years ago | 0

Answered
How to Input a function equation in matlab
>> b = 1; >> a = 2; >> hm = 0.5; >> kt = 0.9; >> fun = @(F) F - hm*(a-b)*log(1+F/(hm*(a-b))); >> y = fzero(@(x)...

8 years ago | 0

Load more