Answered
To set value based on condition in a matrix
Here is an example. % First make the matrix and get the needed numbers... A = zeros(ceil(rand(1,2)*10)+1); % The matri...

13 years ago | 0

Answered
Is this a Possible MATLAB bug? (Further strange Behavior)
According to the documentation, " _The MATLAB software creates the ans variable automatically when you specify no output argu...

13 years ago | 1

Answered
Using ' findobj ' command and then determining the figure objects from the list of handles
You can narrow your search to specific object types in only specific figure windows. findobj(1,'type','line') % Finds only ...

13 years ago | 0

Answered
how to avoid using num2cell when dealing to structure arrays?
There is a way to do it, and it will be faster (at least it is here): for ii = 1:length(b) a(idx(ii)).a = b(ii); ...

13 years ago | 1

| accepted

Answered
Summing within an array to change the size
Here is one way to do it: A = magic(6); cellfun(@(x) sum(x(:)),mat2cell(A,2*ones(1,3),2*ones(1,3)))

13 years ago | 0

Answered
how speed up or avoid loops
This is much faster. Note that you are masking a very valuable MATLAB function by naming a variable 'sum' in your loop! Please...

13 years ago | 1

| accepted

Answered
how to throw out certain intervals.
Is this what you want? X = [ 2 3 4 57 36 2 ]; Y = X(X>10) I take it this is what you are after because of a loop you ...

13 years ago | 0

Answered
Using i and j as variables
Yes, I ran into much trouble in my early days of MATLAB using i and j as indices in signal processing and data manipulation code...

13 years ago | 5

| accepted

Answered
How can I quickly refer to various object handles in my GUI?
Here is how I handle situations like these. I store all handles to a specific type in a structure with a fieldname correspondin...

13 years ago | 0

| accepted

Answered
Double Loop iterations doubt
Is this what you mean? if ~mod(i,12) j = j + 1; end I am assuming here that j is set outside the loop you sho...

13 years ago | 1

| accepted

Answered
Search and Compare Arrays
I assume the temperatures in B exactly match those in A? In other words, you are not interpolating. First the FOR loop you req...

13 years ago | 1

| accepted

Answered
Problem with markers & dashed lines in figures containing both plot and fill
This is a problem with the opengl renderer. When you have a transparency, you are using opengl, and it can be buggy. To see th...

13 years ago | 1

| accepted

Answered
Error: Not enough input argument (line 6)
The error is not in the function, but in the way you called it. You called it with no input arguments.

13 years ago | 1

| accepted

Answered
changing an image to rgb format
A png is already 3D. I have an image named IMG.png in my directory. Now look: >> X = imread('IMG.png'); >> whos ...

13 years ago | 0

| accepted

Answered
Which solver to use? I cannot get an answer, though I know there is one.
Use: ROOT = solve(lhs-rhs,'L'); There are other roots. You might just want to use FZERO: fzero(@(x) subs(lhs,x...

13 years ago | 0

| accepted

Answered
Slider for Multiple Plots in GUIDE
Here is a simple example GUI. Note that the same principle applies in GUIDE. function [] = slider_plot() % Plot dif...

13 years ago | 1

| accepted

Answered
Generate a matrix of 1 and 0
Is this what you mean: A =[4 5 3 2 4 2 1 4]; U = unique(A); B = zeros(max(U)); for ii = U B(A==ii,ii) =...

13 years ago | 0

| accepted

Answered
GUI GUIDE Error with Map
You clear long and lat, then immediately try to use them. This is your error. You also rely on Poofing variables into your wor...

13 years ago | 0

| accepted

Answered
Accessing cell array via factor/index
I assume you mean that the each row in the third column contains one of 'fs','pre','sv',or 'to', not all 4! This snippet finds ...

13 years ago | 0

Answered
how to write a loop
Instead of using: for i=1 use if i==1 (And it is generally not recommended to mask MATLAB functions in your co...

13 years ago | 0

Answered
How can I forecast an integer related to other 5 numbers?
Here is another way that uses no toolbox. Find the weights.... % First the data. D = [33 48 47 68 79 6; 26 32 3...

13 years ago | 0

Answered
Why does dir('*.mat') not list all of the .mat files in directory?
Are you sure about those files being in there? Does WHAT see them (type: what) in there? D = dir; length(regexp([D(:).n...

13 years ago | 0

| accepted

Answered
How can I fill a plot section from a single x,y coordinates?
I would fill it with a patch object. line([1 1],[0 100],'color','b','linewidth',3); hold all verts = [[0;1;1;0],[...

13 years ago | 0

| accepted

Problem


Find the repeating decimal pattern!
Write a function that takes one double input value and returns only the repeating decimal, if any, as a string. Only decimals f...

13 years ago | 2 | 14 solvers

Answered
while loop; a small problem
This loop, as you written it, should always 'get stuck' because k does not change inside the loop. What are you trying to do wi...

13 years ago | 0

Answered
How can I get the index of the selected item in a pop-up menu within a uitable?
I don't see how to do this. The best I can suggest to you is to use <http://www.mathworks.com/matlabcentral/fileexchange/14317-...

13 years ago | 0

Answered
Converting rad to deg in a static text box GUI?
The problem is that you are passing ANGLEDIM a string and expecting a string output. It takes and returns doubles, not strings....

13 years ago | 0

| accepted

Answered
How do I correct this plot code?
Whenever you mean to multiply (or divide) a vector by a vector on an element-by-element basis, you must use the (.*) or (./) ope...

13 years ago | 0

Answered
Can interp1 function be used when the time interval of data isn't uniform?
When I have a question like this, I just do a little experiment. x = sort(rand(1,30)*2*pi); % Non-uniform data y = sin...

13 years ago | 1

Load more