Answered
sum of series. Vectorised (no loop)
You can calculate the sum of a finite alternating harmonic series easy enough: N = 1000; n = 1:N; s = sum((2*mod(n,2)-1)./n) ...

5 years ago | 0

Answered
Problem with vertically Concatenating vectors in a function
% a cell array of numeric row vectors A = {1:3,10:14,1:5} % all row vectors concatenated into a col vector bigcolvec = [A{:...

5 years ago | 0

Answered
plot3 with implicit domain
Maybe something like this? n = 50; u = linspace(-2,2,n); v = linspace(-2,2,n)'; f = u.^2 - v.^2; % the function dm = (u.^...

5 years ago | 2

| accepted

Answered
How to check for a zero in any row of a particular column in an [50000, 50000]?
Depends what you mean by "lowest position of row". Consider the example: firstzerorow = find(A(:,thiscolumn)==0,1,'first'); ...

5 years ago | 0

Answered
Loop with several conditions
Maybe this is a start. % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % build example data A = zeros([240 3]); for d=1:10 ...

5 years ago | 2

| accepted

Answered
Plot colouring from a value?
If you're trying to set regions of the plot background, consider the example: % example data t = linspace(0,8.5*pi,100); f = ...

5 years ago | 0

Answered
Trying to use output values of a previously defined function for another function, can't figure it out for some reason
k is a function with one input argument. If you try to call it like this: k() you'll get an error because there aren't enough...

5 years ago | 0

Answered
Check if all values in cell array are 'on'
Consider the example A = {'on'}; A = repmat(A,[10 1]) % A{2} = 'off' % uncomment to test the response to the existence of an ...

5 years ago | 0

| accepted

Answered
How can I write three different size vectors in a matrix ?
This probably isn't the most robust way, but here's my try. i = [1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20]; k = [3 5...

5 years ago | 1

| accepted

Answered
Checking a specific element of 4x1 matrix being 1
More than likely, this is a case of rounding error. Beware strict equality tests with floating point numbers. That 1.000000000...

5 years ago | 0

| accepted

Answered
What is the difference between drawrectange and rectangle?
To my understanding, rectangle() is an older function which serves to draw rectangular or rounded rectangular graphical objects....

5 years ago | 1

| accepted

Answered
Finding correct row in array with multiple columns matching different conditions
Maybe something like this: A = [1 2 3; 4 5 6]; % 2 rows and 3 columns B = [1 1 2; 1 2 3; 2 2 4; 3 4 5; 4 5 6]; % 5 rows and 3 ...

5 years ago | 0

| accepted

Answered
Unable to apply an if condition x^2+y^2=a^2;
This is a logical test that's not being assigned to any variable. It does nothing but dump to console. x.^2+y.2<=a.^2 You hav...

5 years ago | 1

Answered
Index exceeds the number of array elements for runge kutta method
Your loop goes from 1:4 for i = 1:4 k1 = f(x(i),y(i)); but your vectors only have 2 elements. x =[0,4]; % set the inter...

5 years ago | 0

| accepted

Answered
GUI sliders for contrast and brightness used at once on one picture
The contrast slider CBF creates a copy (I) of the source image, and generates the working image (currentimage). The brightness ...

5 years ago | 0

Answered
Making White Pixels in an Opaque TIF Image Transparent and Saving as a PNG
Yeah imwrite() is really clumsy about handling certain file types and options. For PNG, the alpha channel has to be separated a...

5 years ago | 0

| accepted

Answered
How do i change the size of displayed images in a figure ?
There's a couple things going on here. Not knowing what plot commands you're using, I'll just start with an example. I'm goin...

5 years ago | 0

| accepted

Answered
create a grid and label on the images Using for loop
Well okay, if you don't want to explain anything, I'll just make my own assumptions. You said you want to create a grid, but th...

5 years ago | 1

Answered
grayscale to RGB in matlab
It depends what you mean when you say you want an RGB image. Consider the following image: You can make a single-channel g...

5 years ago | 1

| accepted

Answered
Plot convolution of two wave signals
The length of the result of convolving two vectors is the sum of the vector lengths. Try this: fs=10^6; T=1/fs; tt=0:T/100:3...

5 years ago | 0

| accepted

Answered
Showing actual values in colorbar 2D scatter plot
caxis([2 102])

5 years ago | 0

| accepted

Answered
Finding a value in a specific row within a matrix (c) closest to 700. Then telling me what column this value is situated.
What's wrong with just doing this? A = magic(10) % dummy test matrix row = 4; % look in this row findthisvalue = 21 % for t...

5 years ago | 0

Answered
extract without change my NaN value
Consider: nanmask=isnan(myarray); % keep track of nans outputarray=functionthatdoesthings(myarray); % do a thing outputarray...

5 years ago | 0

Answered
My array has about 15,000,000 indices, however error "Index in position 1 is invalid. Array indices must be positive integers or logical values." shows up
I've never run across something like this, so this is just a naive hunch. I'm curious to know if changing i = size +1; to ...

5 years ago | 0

| accepted

Answered
Using output variables from one function as inputs for another
Not knowing what processdata() does or whether it has any outputs at all, I can't say. When you define a function, define its...

5 years ago | 1

Answered
How to fixe the For loop
You need to use == for equality tests, not =. That said, don't try testing character arrays for equality that way either. Unle...

5 years ago | 0

Answered
Is this the expected behavior of imapplymatrix() with explicit output class parameter?
Well, again, I guess I'll resolve my own question without actually answering the core curiosity. I'll just assume that the cumb...

5 years ago | 0

| accepted

Answered
Attempted to access index 2 of an array with smaller dimension sizes.
The error means what it says. You're trying to index into element 2 of a scalar. This variable is a scalar. It's defined as s...

5 years ago | 0

Answered
Intersect between functions. I am trying to get the intersection between three functions in 3D space.
something like this: syms x y z e1 = (x -2.*y + 5)==z; e2 = (2.*x -4.*y + 6)==z; e3 = (-x -4.*y + 1)==z; sol = vpasolve([...

5 years ago | 0

Answered
using a variable to change destination path in movefile
The first argument here needs to be a string, so put it in quotes (and pay attn to case) movefile('C:/Users/alast/Documents/LAB...

5 years ago | 0

| accepted

Load more