Community Profile # Rik

Last seen: Today Active since 2017

E-mails with feedback/questions about FEX submissions are welcomed. In general I will post e-mails about Answers on the related page, unless there is good cause not to do so.

#### Statistics

All
• • • • • • • • • • • • #### Content Feed

View by

Update elements in matrix with condition
N = size(P,1); for k = 1:1:N if P(k,5) == 0 P(k,3) = P(k,1) + P(k,3); end end Similar code will allow y...

alrededor de 11 horas ago | 0

how to convert 1x2 double into two 1x1
It looks like this is what you want: x=Time_msg_match(61649); x=x{1};

4 días ago | 0

Is the formula given the same as the code?
Since the exponents range from -1 to -7, that means you will need 7 different values for t. One of the ways to achieve that is i...

5 días ago | 0

| accepted

I have a code but it keep saying "invalid expression. when calling a function or indexing a variable, use parentheses. otherwise check for mismatched delimiters.
The reason is these two lines: xx1=(0,8.*pi,1000) x3=(-4,4) Did you maybe forget linspace? Anyway, this isn't valid Matlab s...

6 días ago | 0

Submitted

regexp_outkeys
Regexp with outkeys in old releases

why \pi don't work??
Why did you expect it to? This isn't LaTeX. If you want the pi symbol in a character vector that is possible: char(960) Or yo...

7 días ago | 0

arrays have incompatible sizes for this operation help me PLZ
I have removed all the plotting code and included calls to size to determine the sizes of all the variables involved. data_size...

9 días ago | 0

How can I load .mat files?
Or: matfilenames={'Datasets/a.mat','Datasets/b.mat','Datasets/c.mat'}; for k = 1:3 S=load(matfilename{k}); fields=fi...

9 días ago | 1

| accepted

How to fix "Error using == Arrays have incompatible sizes for this operation." in this code?
Let's have a look at the line that results in an error: n1=(sum(x.*y)-length(d)*mean(x)*mean(y))/(sum(x.^2)-length(d)*(mean(x)*...

9 días ago | 0

The Problem with clc; clear; close all; ?
My main point is that people will get into the habit of using this, and will also use it in functions. Clear is almost never ...

10 días ago | 0

| accepted

Stop using suggested word on right arrow
I just checked for you: If you go to the preferences (in the 'Home' tab), you can disable the automatic completions in the MATL...

11 días ago | 1

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

11 días ago | 1

| accepted

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

12 días ago | 0

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

12 días ago | 0

| accepted

finding data from unique id in two tables
You can use the ismember function.

12 días ago | 1

| accepted

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

13 días ago | 1

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

14 días ago | 0

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

14 días ago | 1

| accepted

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

18 días ago | 0

| accepted

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

19 días ago | 1

| accepted

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

19 días ago | 0

| accepted

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 ]; ...

21 días ago | 0

| accepted

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

21 días ago | 0

| accepted

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

21 días ago | 0

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

22 días ago | 0

| accepted

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

22 días ago | 0

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

22 días ago | 0

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

22 días ago | 1

| accepted