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

mehr als 10 Jahre vor | 1

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

mehr als 10 Jahre vor | 1

| akzeptiert

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

mehr als 10 Jahre vor | 0

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

mehr als 10 Jahre vor | 0

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

mehr als 10 Jahre vor | 1

| akzeptiert

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

mehr als 10 Jahre vor | 0

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

mehr als 10 Jahre vor | 2

| akzeptiert

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

mehr als 10 Jahre vor | 0

| akzeptiert

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

mehr als 10 Jahre vor | 0

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

mehr als 10 Jahre vor | 0

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

mehr als 10 Jahre vor | 0

| akzeptiert

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

mehr als 10 Jahre vor | 0

| akzeptiert

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

mehr als 10 Jahre vor | 1

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

mehr als 10 Jahre vor | 0

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

mehr als 10 Jahre vor | 0

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

mehr als 10 Jahre vor | 0

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

mehr als 10 Jahre vor | 0

| akzeptiert

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

mehr als 10 Jahre vor | 3

| akzeptiert

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

mehr als 10 Jahre vor | 0

| akzeptiert

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

mehr als 10 Jahre vor | 1

| akzeptiert

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

mehr als 10 Jahre vor | 0

| akzeptiert

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

mehr als 10 Jahre vor | 0

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

mehr als 10 Jahre vor | 0

| akzeptiert

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

mehr als 10 Jahre vor | 0

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

mehr als 10 Jahre vor | 0

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

mehr als 10 Jahre vor | 0

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

mehr als 10 Jahre vor | 0

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

mehr als 10 Jahre vor | 1

| akzeptiert

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

mehr als 10 Jahre vor | 0

| akzeptiert

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

mehr als 10 Jahre vor | 0

Mehr laden