Answered

Unable to use a value of type 'cell' as an index

You need to unwind the call to see what's going on. When you create r_4, you have set UniformOutput to false. That means it i...

Unable to use a value of type 'cell' as an index

You need to unwind the call to see what's going on. When you create r_4, you have set UniformOutput to false. That means it i...

3 meses ago | 1

| accepted

Answered

Extracting every row from a matrix using a for loop

This might not be optimal, depending on what you want to do, but the size function is here to help: data=rand(23999,31) for ro...

Extracting every row from a matrix using a for loop

This might not be optimal, depending on what you want to do, but the size function is here to help: data=rand(23999,31) for ro...

3 meses ago | 0

Answered

Loop in a string array and changing string

Why didn't you mention this is homework? (I have seen this exact situation from another user this week, so barring evidence to t...

Loop in a string array and changing string

Why didn't you mention this is homework? (I have seen this exact situation from another user this week, so barring evidence to t...

3 meses ago | 0

| accepted

Answered

finding data from unique id in two tables

You can use the ismember function.

finding data from unique id in two tables

You can use the ismember function.

3 meses ago | 1

| accepted

Answered

Matrix-vector operations without loops

You can use permute to reshape the second array and use the implicit expansion to do the multiplication in one go. Then sum over...

Matrix-vector operations without loops

You can use permute to reshape the second array and use the implicit expansion to do the multiplication in one go. Then sum over...

3 meses ago | 1

Answered

There is an apparent error in line 4, and this code only ran once

t = [36, 65, 100, 160]; c = [0.145, 0.120, 0.100, 0.080]; t2 = (20:10:160); c2 = b*exp(t2*m); As you can see, you didn't def...

There is an apparent error in line 4, and this code only ran once

t = [36, 65, 100, 160]; c = [0.145, 0.120, 0.100, 0.080]; t2 = (20:10:160); c2 = b*exp(t2*m); As you can see, you didn't def...

3 meses ago | 0

Answered

Inside of a for loop. How to call another script lets say (IK.m) as Ik sub every time the loop goes to a new point?

I don't see how exactly you would end up with 6 values for each point, but if you convert your script to a function, that will m...

Inside of a for loop. How to call another script lets say (IK.m) as Ik sub every time the loop goes to a new point?

I don't see how exactly you would end up with 6 values for each point, but if you convert your script to a function, that will m...

3 meses ago | 1

| accepted

Answered

save data all of in loop

No loop required: num=xlsread('ENVISAT.ex.xlsx'); num=num(~isnan(num)); num=nonzeros(num); lon=num(1:2:end); lat=num(2:...

save data all of in loop

No loop required: num=xlsread('ENVISAT.ex.xlsx'); num=num(~isnan(num)); num=nonzeros(num); lon=num(1:2:end); lat=num(2:...

3 meses ago | 0

| accepted

Answered

Including external file is making workspace messy

Let me expand on the suggestion of @Mathieu NOE: Use functions, not scripts. Each function should have documentation explaining...

Including external file is making workspace messy

Let me expand on the suggestion of @Mathieu NOE: Use functions, not scripts. Each function should have documentation explaining...

3 meses ago | 1

| accepted

Answered

Create matrix using the array as index

You don't even need a loop: a=[2 2 1 0 3]; ind=a+1; A=zeros(max(ind),numel(ind)); ind=sub2ind(size(A),ind,1:numel(ind)); ...

Create matrix using the array as index

You don't even need a loop: a=[2 2 1 0 3]; ind=a+1; A=zeros(max(ind),numel(ind)); ind=sub2ind(size(A),ind,1:numel(ind)); ...

3 meses ago | 0

| accepted

Answered

deleting separate zeros from vector

It took a bit of thinking, but here is a oneliner: A = [ 0 0 1 0 0 0 1 0 1 0 0 1 5 9 8 2 0 3 0 1 0 0 0 ]; ...

deleting separate zeros from vector

It took a bit of thinking, but here is a oneliner: A = [ 0 0 1 0 0 0 1 0 1 0 0 1 5 9 8 2 0 3 0 1 0 0 0 ]; ...

3 meses ago | 0

| accepted

Answered

How can I interrupt a for or while loop by pressing a button 2?

You can tell Matlab to process callbacks with the drawnow function. If you put a call to drawnow just before you reload the val...

How can I interrupt a for or while loop by pressing a button 2?

You can tell Matlab to process callbacks with the drawnow function. If you put a call to drawnow just before you reload the val...

3 meses ago | 0

| accepted

Answered

Input the same value into a cell array that each cell contains different fits?

I don't think there is a way to actually avoid a loop. You can avoid a double loop like this: results=zeros(size(CellWithFitObj...

Input the same value into a cell array that each cell contains different fits?

I don't think there is a way to actually avoid a loop. You can avoid a double loop like this: results=zeros(size(CellWithFitObj...

3 meses ago | 0

Answered

Compare two vectors in matlab n*m

You mean like this? A=[1 2 3 4 5 6 7 8 9 10]; B=4; result=zeros(size(A));%pre-allocate L= A<B ;result(L)=1; L= A==B;resul...

Compare two vectors in matlab n*m

You mean like this? A=[1 2 3 4 5 6 7 8 9 10]; B=4; result=zeros(size(A));%pre-allocate L= A<B ;result(L)=1; L= A==B;resul...

3 meses ago | 0

| accepted

Answered

Gui problem with workspace

Why do you want to use evalin? Just have your functions return outputs. Every function has its own workspace. To share data bet...

Gui problem with workspace

Why do you want to use evalin? Just have your functions return outputs. Every function has its own workspace. To share data bet...

3 meses ago | 0

Answered

How can I plot a lot of data sets quickly?

Make sure you load the data to an array instead of numbered variables. That way you can use a simple for loop and indexing. htt...

How can I plot a lot of data sets quickly?

Make sure you load the data to an array instead of numbered variables. That way you can use a simple for loop and indexing. htt...

3 meses ago | 0

Answered

Backward compatible functionSignatures.json

In that case my proposed solution would be implementing something like Jan suggested in his answer. Write a function similar to...

Backward compatible functionSignatures.json

In that case my proposed solution would be implementing something like Jan suggested in his answer. Write a function similar to...

3 meses ago | 1

| accepted

Answered

Utilizing sqrt and square, "Check for incorrect argument data type or missing argument in call to function 'sqrt'"

As Stephen mentioned, the sqrt function expects either single or double. So you will have to convert it to either of those data ...

Utilizing sqrt and square, "Check for incorrect argument data type or missing argument in call to function 'sqrt'"

As Stephen mentioned, the sqrt function expects either single or double. So you will have to convert it to either of those data ...

4 meses ago | 0

Answered

How to assign the size of a k-th column of a cell to the k+1-th?

When you execute this line: sbc{k}=size(cycles{k+1}) the k+1 element of cycles doesn't exist yet. You will have to make ...

How to assign the size of a k-th column of a cell to the k+1-th?

When you execute this line: sbc{k}=size(cycles{k+1}) the k+1 element of cycles doesn't exist yet. You will have to make ...

4 meses ago | 0

Answered

How to store values from nested for loop

The first step to implement a summation in Matlab is very easy: just use a for loop. It is often possible to do this with a matr...

How to store values from nested for loop

The first step to implement a summation in Matlab is very easy: just use a for loop. It is often possible to do this with a matr...

4 meses ago | 1

| accepted

Answered

How to create a matrix with nested for loop for fraction entries?

Why use loops at all? y=1; ii=0.5:.1:.7; jj=.4:.1:.6; [ii,jj]=ndgrid(ii,jj); mat=ii.*y.*jj; disp(mat)

How to create a matrix with nested for loop for fraction entries?

Why use loops at all? y=1; ii=0.5:.1:.7; jj=.4:.1:.6; [ii,jj]=ndgrid(ii,jj); mat=ii.*y.*jj; disp(mat)

4 meses ago | 1

Answered

Having error when ploting bars with filled pattern

Download the applyhatch_plusC function from the FileExchange here and add it to your path somewhere (or your current folder). N...

Having error when ploting bars with filled pattern

Download the applyhatch_plusC function from the FileExchange here and add it to your path somewhere (or your current folder). N...

4 meses ago | 0

Answered

Appending a file with a string output and a numeric output

Use the 'a', 'a+', or 'A' flags in fopen to append data. This should work for text files as well. You don't really need the 't' ...

Appending a file with a string output and a numeric output

Use the 'a', 'a+', or 'A' flags in fopen to append data. This should work for text files as well. You don't really need the 't' ...

4 meses ago | 1

Submitted

ifversion

Determine if the current version satisfies a version restriction

4 meses ago | 3 downloads |

Answered

mex - setup FORTRAN can't install for 2017b or 2021a for windows 10

MinGW is only for C an C++, not Fortran. The linked page looks like you need the Intel Parallel Studio XE. The 2017 version s...

mex - setup FORTRAN can't install for 2017b or 2021a for windows 10

MinGW is only for C an C++, not Fortran. The linked page looks like you need the Intel Parallel Studio XE. The 2017 version s...

4 meses ago | 0

Answered

why the command "figure(gcf+1)" gives error?????

The gcf get the handle to the current figure. In old releases this used to be a double, but since several years ago it has been ...

why the command "figure(gcf+1)" gives error?????

The gcf get the handle to the current figure. In old releases this used to be a double, but since several years ago it has been ...

4 meses ago | 0

| accepted

Answered

How to vectorize nested for loops

ndgrid will do the trick: rowsA=59; pix = 25.4/600; R = 2.5; ht = 1.5; A=abs(-rowsA:rowsA); % e.g. 5 4 3 2 1 0 1 2 3 4 5 size...

How to vectorize nested for loops

ndgrid will do the trick: rowsA=59; pix = 25.4/600; R = 2.5; ht = 1.5; A=abs(-rowsA:rowsA); % e.g. 5 4 3 2 1 0 1 2 3 4 5 size...

4 meses ago | 0

| accepted

Answered

New. to Matlab, can you help me with the code?

A much better solution is to learn Matlab with a tutorial. You may consider doing the Onramp tutorial (which is provided for fre...

New. to Matlab, can you help me with the code?

A much better solution is to learn Matlab with a tutorial. You may consider doing the Onramp tutorial (which is provided for fre...

4 meses ago | 1

Answered

Have problem in solution

It looks like you want different things to happen depending on the value of Erf: for every element smaller than 2 you want y to ...

Have problem in solution

It looks like you want different things to happen depending on the value of Erf: for every element smaller than 2 you want y to ...

4 meses ago | 0

| accepted