已回答
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...

10 years 前 | 1

已回答
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...

10 years 前 | 1

| 已接受

已回答
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...

10 years 前 | 0

已回答
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...

10 years 前 | 0

已回答
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 ...

10 years 前 | 1

| 已接受

已回答
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...

10 years 前 | 0

已回答
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...

10 years 前 | 2

| 已接受

已回答
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...

10 years 前 | 0

| 已接受

已回答
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...

10 years 前 | 0

已回答
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...

10 years 前 | 0

已回答
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...

10 years 前 | 0

| 已接受

已回答
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 ...

10 years 前 | 0

| 已接受

已回答
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...

10 years 前 | 1

已回答
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...

10 years 前 | 0

已回答
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...

10 years 前 | 0

已回答
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...

10 years 前 | 0

已回答
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 ...

10 years 前 | 0

| 已接受

已回答
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...

10 years 前 | 3

| 已接受

已回答
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...

10 years 前 | 0

| 已接受

已回答
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...

10 years 前 | 1

| 已接受

已回答
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...

10 years 前 | 0

| 已接受

已回答
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 ...

10 years 前 | 0

已回答
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 ...

10 years 前 | 0

| 已接受

已回答
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...

10 years 前 | 0

已回答
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 ...

10 years 前 | 0

已回答
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)...

10 years 前 | 0

已回答
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...

10 years 前 | 0

已回答
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...

10 years 前 | 1

| 已接受

已回答
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...

10 years 前 | 0

| 已接受

已回答
xlwrite not writing when complied using Application Compiler
If no error is being thrown by xlwrite, chances are your current directory at runtime is not where you think it is. You could...

10 years 前 | 0

加载更多