回答済み
how to run function for several times with different variables
In your example you do not need more than one variable: a=[5 8 9 11]; for i=1:numel(a) n=a(i)*0.1:a(i)*0.1:a(i); for...

6年弱 前 | 0

回答済み
Correct evaluation of a logical statement, incorrect result?
It would be helpful to see your code, to find any errors. This should work fine: A=rand(96,6); D=5; B=zeros(96,6); C=3*one...

6年弱 前 | 1

| 採用済み

回答済み
Reshaping an 1x365 matrix with daily observations within a year
You could add some zeros/NaNs at the end of your 365 datapoints, then you should be able to reshape: A=randi(100,365,1); A(e...

6年弱 前 | 0

回答済み
script for looping function
You just need to get rid of the (t,f1,f2) before the '=' when defining your function. You need to take a look at your loop aswel...

6年弱 前 | 0

回答済み
GUI handle structure not updating
You can use drawnow to update your graphic elements: function figure1_WindowKeyPressFcn(hObject, eventdata, handles) key = get...

6年弱 前 | 0

| 採用済み

回答済み
How to write a code for an iteration?
f=zeros(100,4); f(1,:)=[1 5 10 15]; for i=2:100 f(i,:)=[f(i-1,1)+f(i-1,2),f(i-1,3)+f(i-1,4),f(i-1,1)-f(i-1,2),f(i-1,3)-f(...

約6年 前 | 0

| 採用済み

回答済み
Please help me fix the count for the nested for-loop
Your addHexNumber function actually does not work correctly. I think you need to change if bothSum > 16 to if bothSum > ...

約6年 前 | 1

回答済み
Indexing a variable value
function density = FindDensity(DataDensity,position) [~,idx]=min(abs(DataDensity(:,1)-position)); density=DataDensity(idx,...

約6年 前 | 0

回答済み
Problem with for loop
The problem is that find might return an empty vector and in that case the assignment fails. You could catch this error by che...

約6年 前 | 1

回答済み
How can I create a function that inputs a row
You can read about functions here. function res=myfunc(matrix,row) %function [output1,output2]=functionname(input1,input2) ...

6年以上 前 | 0

回答済み
I need a 'reset' push button to reset all other push buttons
Without seeing your code it is hard to provide an answer. If the enabling works your probably did not set the string property of...

6年以上 前 | 1

回答済み
How to allow user to retrieve indices for particular value in an array, not the value itself?
In your example you use the _find_ function on only 1 value ( _min()_ returns 1). You were close, _min()_ can actually return...

6年以上 前 | 0

| 採用済み

回答済み
Why do I receive empty outputs in cell arrays after an if statement?
You nested your if statements, hence the last statement if C(j,2) < crvalue{1} will only be executed if the previous sta...

6年以上 前 | 2

| 採用済み

回答済み
how to construct if for vectors with positive and negative?
Small example to understand what is happening: Lets take a vector and check if all values are >0. test=1:5>0 In t...

6年以上 前 | 1

| 採用済み

回答済み
Keep getting this error code: Unable to perform assignment because the indices on the left side are not compatible with the size of the right side.
The left side is a single field in a matrix numericalData(i), this could for example be a number or a string. The right side is ...

6年以上 前 | 0

| 採用済み

回答済み
How can I fix the error "Index exceeds matrix dimension"
bcdof1 is a column vector you need to index bcdof1(i,1) instead of bcdof(1,i) bcdof1=[1;4;34;35;36]; bcdof=zeros(1,2*len...

6年以上 前 | 1

| 採用済み

回答済み
fprintf and for loop
for i=1:10 for j=1:2 fprintf('period %d step %d \nsave\n',i,j) end end

6年以上 前 | 0

| 採用済み

回答済み
Check an array of values if within an upper and lower limit
If you want to operate on arrays you could do it like this: x = 1:10; minVal = 2; maxVal = 6; x(x(x<=maxVal)>=minV...

6年以上 前 | 0

| 採用済み

回答済み
For loop with Else statement
My guess is that you want to set every value in RR to 0 after the cumulative sum reaches 3000. Here is why this does not work...

6年以上 前 | 0

回答済み
If statement with many logical or.
You are comparing floating point numbers, which will not necessary work: 1-0.4-0.2==0.4 ans = 0 You c...

6年以上 前 | 0

| 採用済み

回答済み
Index in position 1 exceeds array bounds (must not exceed 4079). how to rectify this error
You are passing Hist and testIDs to your cal_AP function. In that function your try to access Hist(tesIDs). Hist has 4079 row...

6年以上 前 | 0

| 採用済み

回答済み
For the code below how would I make it ALWAYS select and set the upper left corner to be 1 always no matter what the n value is (10, 1000, 1000000)?
I am only guessing, but i assume you want nodetype(1,1) to be 1? The easiest way of doing this would be: nodetype(1,1)=1; ...

6年以上 前 | 0

回答済み
use logical indexing to access multiple lines syntax
Almost there ;) in p you have the row positions: p552r1kmeans=p552r1_tnL(p,1:3)

6年以上 前 | 1

回答済み
Problem with quiver plot function
You got a typo: Qplot(handles.edit22.String, h.latf, h.lonf, h.uf. h.vf, handles.edit21.String, handles.edit23.String) ...

6年以上 前 | 2

| 採用済み

回答済み
Conditional with string wildcard
You should get a warning that Text1 ='Tree'*; is no valid syntax (the * is a problem). If you want to use * as a wildc...

6年以上 前 | 0

回答済み
Loop is not working. My while loop is not working. output is initial values here. Can anyone help??
C is not a vector/matrix it is a scalar. C(counter) can not work for any value of counter >1. C(0.1) will not work either.

6年以上 前 | 0

| 採用済み

回答済み
Subscript indices must either be real positive
The error is actually not that straight forward. Many floating point numbers can described 100% accurate in binary form. So your...

6年以上 前 | 1

回答済み
How are multiple for loops handled by matlab?
This depends on how you nest your loops: for k=1:100 for n=[10,50,70] %this is the inner loop it will be executed 100 t...

6年以上 前 | 0

回答済み
Changing the matlab seed
You can use rng('shuffle') For more information have a look <https://de.mathworks.com/help/matlab/math/why-do-random-nu...

6年以上 前 | 0

回答済み
I am trying to create an if/else staement over a range of values and display the corresponding value for each values variable. Ex if a<5 then c=2 b=1 else c=3 b=4 but over a range of a values displaying each c or b value for each of the a values
It is not 100% clear to me what you want to do, however you can use elseif for multiple statements: a=5; if a==4 else...

6年以上 前 | 0

| 採用済み

さらに読み込む