Answered
converting values in cell array
I can't imagine a use-case for this, but here you go: A = {[1,2,3],[5,6,7],[13,14,15]}; B = cell(size(A)); counter=0;...

9 years ago | 0

Answered
Is there ever a good time to use elseif?
There's a pretty good answer in the context of Java <http://stackoverflow.com/questions/9169249/why-we-use-if-else-if-instead-of...

9 years ago | 1

Answered
How to speed up function evaluation by vectorization
The second loop seems fine. Vectorization of loop 1 below. % rho_int=zeros(16); % Loop 1 replaced by vector operation rh...

9 years ago | 1

| accepted

Answered
Find if any string in a cell array is contained in a string
Have you tested the speed of a for-loop or cellfun()? It's probably your best bet here unless C contains a really large number o...

9 years ago | 0

Answered
arccosine and operands greater than 1
In the Mathworks documentation for <http://www.mathworks.com/help/matlab/ref/acos.html acos> (), you can click the <http://www.m...

9 years ago | 0

Answered
How to find rows with multiple entries that are equal?
In two lines: sA=sort(A,2); A(sum(sA(:,2:end)==sA(:,1:end-1),2)==size(sA,2)-2,:) ans = 2 2 2 1 ...

9 years ago | 1

| accepted

Answered
using the find function using conditions
Try applying abs() to the diffs - you might have the direction of your circle wrong. Also one of those hdg inequalities should b...

9 years ago | 0

Answered
Run for loop and print data after each iteration
Hi monkey_matlab, When you write "volt_ii" (or "Dataii") Matlab will not resolve it to volt_1 (or Data1). Matlab reads this a...

9 years ago | 2

| accepted

Answered
Parallel nested for-Loop with a compounding variable
Each iteration of a parfor loop will be performed in an unpredictable order. Therefore Matlab prevents you from changing the val...

9 years ago | 0

| accepted

Answered
How to plot to axes instead figure?
If you want to plot on a specific graphics object, you should *pass the handle of that object into your plotyyy function*. You c...

9 years ago | 0

Answered
Swapping values within a vector if the one after it is greater than the one before it.
First off, what you're doing isn't a swap. You're overwriting x(k) but what about x(k+1)? It's still retaining it's original val...

9 years ago | 0

Answered
Disable variable replacement notification without disabling variable replacement
Not sure if there's a better solution, but you can simply hit the escape when the dialogue box appears. This keeps your cursor i...

9 years ago | 0

| accepted

Answered
How to write a loop for vectors?
You can draw your 5 random dice values across all rolls at once (no need to loop). You can then calculate the 5 of a kind, then ...

9 years ago | 0

| accepted

Answered
How to plot data in block?
Get the data into your Matlab workspace using the import data tool or one of the following functions: importdata,dlmread,textsca...

9 years ago | 1

Answered
how can i change Y-axis into log and dont get Warning: Negative data ignored
Hi Zhu, The log function is undefined for negative values. Have a look at the <https://en.wikipedia.org/wiki/Logarithm wiki p...

9 years ago | 0

Answered
Help me please. I am stuck with while loop to find local max/minima .
Your algorithm seems to work fine. It took a different path and found what looks like a lower point. Based on the path of you...

9 years ago | 0

Answered
How to plot part of Date column vs Data
Just about every question about date/time in Matlab has been asked and answered on the internet. Try searching this website or G...

9 years ago | 0

Answered
Plotting at set intervals in a for loop
Wrote a test script that scatters X and Y positions for 100 particles at 5 times as close to (0,1/4,1/2,3/4,1) portion of total ...

9 years ago | 0

| accepted

Answered
Sort stocks into portfolios based on two different stock characteristics
First, you should get rid of the NaN values in B and C by replacing them with something meaningful. If a NaN value in B is consi...

9 years ago | 3

| accepted

Answered
xlswrite is truncating the values from the input matrix to the output files
Hi James, There's no reason xlswrite would truncate your values. In Excel, try clicking a "truncated" number -- the formu...

9 years ago | 0

| accepted

Answered
How to add two tables
Hi Jennifer, Here's code with sample data that performs your task. data=magic(3); % sample data % creating sample table...

9 years ago | 1

| accepted

Answered
Add arrows to surface plot to represent wind direction
I'm posting an example as described in my earlier comment. Code below creates a 10x10 grid of arrows that are all pointing at...

9 years ago | 0

| accepted

Answered
how to write excel spreadsheet from table?- Error using writetable (line 116) Could not start Excel server for export. Export to a text file instead.
Information you might want to include: # What version of Matlab are you running? (e.g. 2015b) # Do you have Excel installed ...

9 years ago | 0

Answered
maintain string in a cov matrix
fede, Your data can be stored in a table. Tables allow you to operate on numeric values while also keeping column headers to ...

9 years ago | 0

| accepted

Answered
How to extract training set from dataset?
If you want to store a subset of your full dataset in memory, like the first 100 rows of the matrix, just use indexing as follow...

9 years ago | 0

Answered
K-means clustering - results and plotting a continuous curve
kmeans is working exactly as expected for the input you're providing. The best 4 centroids are along your line. Perhaps you can ...

9 years ago | 0

Answered
Replace the value in the columns of a matrix
You can switch the loop to iterate over the columns instead of the rows by changing k1=1:size(A,1) to k1=1:size(A,2)...

9 years ago | 0

Answered
why does it tell me "index exceeds matrix dimensions"??
You do not need to write y(x). You have already defined y, so just call it y. Code fixed below: x = 10:30; y = exp...

9 years ago | 0

Answered
Remove duplicate variables depending on a second variable
Hi Marty, Try the code below. % Defining ppn (all at once) ppn = [ {'BG1026';'BG1027';'BG1028';'BG1028';'BG1028';'BG1...

9 years ago | 1

| accepted

Answered
How to write for-loop?
Hi Sergey, This sample code will do what you're looking for: % sample of vectors a=rand(10,1); b=rand(9,1); c=r...

9 years ago | 0

| accepted

Load more