Respondida
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;...

más de 8 años hace | 0

Respondida
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...

más de 8 años hace | 1

Respondida
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...

más de 8 años hace | 1

| aceptada

Respondida
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...

más de 8 años hace | 0

Respondida
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...

más de 8 años hace | 0

Respondida
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 ...

más de 8 años hace | 1

| aceptada

Respondida
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...

más de 8 años hace | 0

Respondida
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...

más de 8 años hace | 2

| aceptada

Respondida
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...

más de 8 años hace | 0

| aceptada

Respondida
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...

más de 8 años hace | 0

Respondida
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...

más de 8 años hace | 0

Respondida
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...

más de 8 años hace | 0

| aceptada

Respondida
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 ...

más de 8 años hace | 0

| aceptada

Respondida
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...

más de 8 años hace | 1

Respondida
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...

más de 8 años hace | 0

Respondida
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...

más de 8 años hace | 0

Respondida
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...

más de 8 años hace | 0

Respondida
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 ...

más de 8 años hace | 0

| aceptada

Respondida
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...

más de 8 años hace | 3

| aceptada

Respondida
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...

más de 8 años hace | 0

| aceptada

Respondida
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...

más de 8 años hace | 1

| aceptada

Respondida
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...

más de 8 años hace | 0

| aceptada

Respondida
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 ...

más de 8 años hace | 0

Respondida
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 ...

más de 8 años hace | 0

| aceptada

Respondida
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...

más de 8 años hace | 0

Respondida
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 ...

más de 8 años hace | 0

Respondida
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)...

más de 8 años hace | 0

Respondida
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...

más de 8 años hace | 0

Respondida
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...

más de 8 años hace | 1

| aceptada

Respondida
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...

más de 8 años hace | 0

| aceptada

Cargar más