Respondida
Recently I create a script in which I take input argument as string.After dividing the first digit with the second digit of number.It calculate the inverse of 2 digits which is not required.I want scalar division.Please guide me where I am wrong
You need to convert your character strings to floating point numbers at the appropriate places in your code. The way you have it...

casi 9 años hace | 1

Respondida
How do I solve system of matrices with a for loop and save each iteration in an array?
You just need to rearrange your code a bit. Currently you are overwriting stuff. Endpoint_forces = NaN(2,101); for i = ...

casi 9 años hace | 0

Respondida
Plot every nth data point
v = your vector t = 1:numel(v); plot(t(30:30:end),v(30:30:end)); % <-- assuming you want to start at 30th element

casi 9 años hace | 3

Respondida
Counting active binary combinations
You are choosing a combination of 64 bits taken 8-to-16 at a time. So add them up: s = 0; n = 64; for k=8:16 ...

casi 9 años hace | 1

| aceptada

Respondida
Numeric array values replaced with zeros
This is just a display issue. The values are still there. E.g., >> x = [-3 10 1e9 4 300] x = 1.0e+009 * -0....

casi 9 años hace | 0

| aceptada

Respondida
How can I overwrite a variable saved in a script that I have to loop with a different value?
Edit the script file blabla.m, and comment out the a = 18 line: % a = 18; Also, make sure the script file blabla.m does ...

casi 9 años hace | 0

Respondida
Can I assign values to an array in a diagonal direction from a reference point on that array?
Yet another method: [M,N] = size(X); n = min(M,N); XXX = repmat(X,3,3); % work with a big matrix so we don't have to...

casi 9 años hace | 0

Respondida
How to accept user input in a lowercase and uppercase?
One approach: switch lower(handles.metricdata.CNO) Then adjust your case conditions to be strictly lower case.

casi 9 años hace | 1

| aceptada

Respondida
Why does this matrix contain different values depending on how it is accessed?
This sparse matrix is invalid. The SPOK utility from the FEX by Tim Davis reveals the problem: >> spok(A) Warning: 2 jumbled r...

casi 9 años hace | 2

| aceptada

Respondida
I am not seeing what is wrong with my code, I've checked doc and help.
You have an inadvertent return statement: else b = c; return <-- get rid of this line The way you h...

casi 9 años hace | 2

Respondida
Can I pull a single character froma string?
See this link for getting substrings from strings: <https://www.mathworks.com/matlabcentral/answers/351195-manipulating-strin...

casi 9 años hace | 1

Respondida
What is the syntax error in this?
Each comment section on a line needs to start with the % character. The C/C++ style of commenting with // does not work with ...

casi 9 años hace | 1

| aceptada

Respondida
I am trying to write a function that will solve ODE's by Runge Kutta's method.. What is wrong in my code?
This s3=f(t+h, y+h*s2); should have x in that first argument, not t. E.g., s3=f(x+h, y+h*s2); And this y...

casi 9 años hace | 0

Respondida
datetime error/inconsistency
This inconsistency has been noted before in previous posts. E.g., with datenum you get the same answer with month=0 and month=1...

casi 9 años hace | 0

Respondida
Could someone please help me trouble shoot the following ode45 code. New to Matlab. Showing multiple errors. Thanks a lot
In your function handle, you are indexing into the d variable with f = @(t,x) [(d(etc... But you have defined d as a sca...

casi 9 años hace | 0

| aceptada

Respondida
Im trying to find the absolute value of the difference between current value 'c' and the values 'n'.
Change n(1,i) to n(i). n is a column vector but you are indexing into it as if it were a row vector. You could use n(i,1), but...

casi 9 años hace | 0

Respondida
How do I append rows and columns into a 3 x 3 Matrix
Ice = [Ice, Avgcol Avgrow, 0 ];

casi 9 años hace | 0

Respondida
resize cell in different dimension
Assuming you mean you want to reshape the cell array itself, and not the _contents_ of the cell array: mycell = your 20x1 c...

casi 9 años hace | 1

Respondida
Why aren't global variables behaving as they should across C-Source files with a common header using mex?
Coding technique advice: When you have top-level global variables shared among multiple source files, I like to have all of the...

casi 9 años hace | 0

Respondida
How to limit the number of for Loops while executing while loops?
In your while loop: while number_of_repeats <= 3 The condition "number_of_repeats <= 3" is always true because the for-lo...

casi 9 años hace | 0

| aceptada

Respondida
How would I suppress function answer and move the answer to a variable all within the function? Homework
Do you mean call the function and put the result into a variable named s? Like this: s = twosum(4,5);

casi 9 años hace | 1

Respondida
Is z an object here? How to interpret the code?
z is a struct. It has a field named "mean".

casi 9 años hace | 0

Respondida
I'm trying to save my script however when i click the green arrow it seems to display an error message. What should i do?
Click the black/blue square disk icon in the upper left to save the file. Clicking the green arrow simply runs the file (and if...

casi 9 años hace | 0

Respondida
How do I write the function to derive an nth taylor polynomial?
You are using the series expansion for cos( ), not the series expansion for exp( ). You need to replace the terms you are using...

casi 9 años hace | 0

| aceptada

Respondida
How to convert the results to a vector?
Form your loop differently. Loop over the indexes of x, not the values of x. E.g., for i=1:numel(x) y(i) = sin(x(...

casi 9 años hace | 0

Respondida
adding elements from cell array to another
m = cellfun(@(A,B)[A B],m,y,'uni',false);

casi 9 años hace | 0

| aceptada

Respondida
Imag, real function error
It could be that you have inadvertently created variables with the name "real" or "imag" that are shadowing the functions real a...

casi 9 años hace | 0

Respondida
generating random values from another matrix with a random value in rows only
Is something like this what you want? Randomly distributed values from X but staying in same column? X = whatever rows ...

casi 9 años hace | 0

| aceptada

Respondida
Write a MATLAB script and user defined function that solves the following orbital equation of motion using ode45
Your code is not even remotely close to what it needs to be for this. In the first place, since you have a 2nd order ODE in 3-s...

casi 9 años hace | 0

| aceptada

Cargar más