답변 있음
Storing a vector in a loop each time with a different name
This is not the best way to do this in MATLAB. There are many, many posts on this site explaining why. Instead, you should use c...

거의 8년 전 | 0

| 수락됨

답변 있음
Rearrange matrix into single row
result = reshape(b.',1,[]); The transpose is needed to get the row values to line up in memory first before doing the resha...

거의 8년 전 | 2

답변 있음
Why do I have 2 outputs instead of 1
The comma in MATLAB is a separator (i.e. forms a "comma-separated-list"), not a decimal point. So typing in 0,1 is equivalent to...

거의 8년 전 | 0

답변 있음
Is it possible to iteratively increase a number within the middle of a file name?
E.g., using sprintf n = some integer sprintf('Myfilename%dwith%dand%dstuff',n,n,n) Sample run: >> n = 5; >> s...

거의 8년 전 | 0

| 수락됨

답변 있음
Subroutine functions in MatLab
Create a file with the following name: init.m Put your code into this file, e.g., function stuff = init stuff = what...

거의 8년 전 | 0

답변 있음
How to calculate argument max for a vector
Assuming "arg max" means index of the max location, use both outputs of the max function p = your vector [m,x] = max(p);...

거의 8년 전 | 0

| 수락됨

답변 있음
How to change values of elements in a sparse matrix
Not sure what your problem is. Sparse matrix elements can be changed directly just like full matrices. E.g., F = your full ...

거의 8년 전 | 1

| 수락됨

답변 있음
Largest value of x such that 2^(-x)>0
If you are talking about the numerical range of IEEE floating point numbers, then the answer depends on the specific bit formatt...

거의 8년 전 | 0

답변 있음
Calculate weighted average of a 2D matrix
E.g., w = 1x481 vector of weights M = your 376x481 matrix of values result = sum(M.*w,2) / sum(w); or sum(bsx...

거의 8년 전 | 0

| 수락됨

답변 있음
Incorrect matrix computation: a*inv(a) does not produce the identity matrix
The "a" matrix you are using is not full rank and does not have an inverse. That is what the warning message is trying to alert ...

거의 8년 전 | 0

| 수락됨

답변 있음
MEX question: How to set scalar and array values within plhs[0] struct?
mxGetField returns a pointer to mxArray, not pointer to double. You need to get at the data with the appropriate function. E.g.,...

거의 8년 전 | 0

답변 있음
Changing elements of an array by row and column using for loop?
You should probably be using size(alpha,1) and size(alpha,2) instead of length(alpha) and size(alpha) in your looping. And you n...

거의 8년 전 | 0

| 수락됨

답변 있음
how to use for loop for below.
This line function area = areaCircle(r) means the function input is r and the output is area. So you need to assign the ...

거의 8년 전 | 0

| 수락됨

답변 있음
Numerical instability of acos
Since you don't show us any code so that we can see where these "funny" values might be coming from, I can only point you to thi...

거의 8년 전 | 0

답변 있음
How to separate M*3 matrix by interval of 1
E.g., maybe something like this? data = your 20x3 matrix x = data(:,1); result = data( 0<x & x<1 ,:);

거의 8년 전 | 1

답변 있음
Initialize a field in all elements of a struct array
Another way using deal: [a(1:numel(a)).field2] = deal(4);

거의 8년 전 | 1

답변 있음
Calculation of Factorial using Recursive Relation
You need the proper formula first: y = n * recursion(n-1); But also you need to figure out how to stop the recursion and...

거의 8년 전 | 0

| 수락됨

답변 있음
How to find value of x such that 2^(-x) =realmin
Just solve your equation directly: x = -log2(realmin) Note that realmin is for the smallest normalized number. Denormali...

거의 8년 전 | 2

답변 있음
Problems with complex output in mex funtion
E.g., just using the definitions in the MATLAB doc: mxComplexInt16 *buf_prueba; : plhs[2] = mxCreateNume...

거의 8년 전 | 0

답변 있음
Finding a 3D parallel vector
A unit vector parallel to the points from (a,b,c) to (d,e,f) is just this: v1 = [a,b,c]; v2 = [d,e,f]; u = v2 - v1; ...

거의 8년 전 | 2

| 수락됨

답변 있음
Obtain maximum value of variable over multiple iterations?
E.g., you could add a variable to your looping for this: altmax = -inf; % your loop start % stuff that calculates...

거의 8년 전 | 0

| 수락됨

답변 있음
How to delete elements from a struct array?
Not exactly sure what you want to do. If you want to delete all structure elements (i.e., all fields for that element) where the...

거의 8년 전 | 2

| 수락됨

답변 있음
Built in Julian Date Converter not working?
What version of MATLAB are you using? juliandate was introduced in R2014b. Are you using an unsupported class variable as one of...

거의 8년 전 | 0

답변 있음
I want to convert a 4x1 vector column to skew symmetric matrix in matlab
You could just use the code you have already typed above. E.g., a = Q(1); b = Q(2); c = Q(3); d = Q(4); S = [0 -a d ...

거의 8년 전 | 0

| 수락됨

답변 있음
How to get a pointer to 2D array when writing a C source Mex file?
You can't use the [j][i] indexing syntax with the pointer returned by mxGetDoubles. You would need to set up a separate pointer ...

거의 8년 전 | 1

| 수락됨

답변 있음
Adding a singleton dimension to a 2D vector
There is no way to force a variable to physically store trailing singleton dimensions past the 2nd dimension. Operations that na...

거의 8년 전 | 2

답변 있음
Why am I getting this error message?
Don't post images of code. This makes it impossible for readers to copy & paste your code for testing. Instead, post the actual ...

거의 8년 전 | 1

| 수락됨

답변 있음
Doubt about matrices mxm
See the following link: <https://www.mathworks.com/matlabcentral/answers/304528-tutorial-why-variables-should-not-be-named-dy...

거의 8년 전 | 0

| 수락됨

답변 있음
Why doesn't the less than operator work inside a for loop for decimals
Floating point arithmetic effects. See this link for starters: <https://www.mathworks.com/matlabcentral/answers/57444-faq-wh...

거의 8년 전 | 2

| 수락됨

더 보기