Save data from a loop with a negative variable

6 Ansichten (letzte 30 Tage)
Patrick Allaglo
Patrick Allaglo am 13 Dez. 2013
Kommentiert: Patrick Allaglo am 13 Dez. 2013
Hey guys :) I have a little question, how can i save data from a loop with a variable evolving between -5 to 5 for example, because when I try to save data by using variable_stored, it says that i have to use positive integer or logical...
  1 Kommentar
The Matlab Spot
The Matlab Spot am 13 Dez. 2013
Correct me if i am wrong
if a = [-5:1:5];
You are not able to save a in a mat file?

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Simon
Simon am 13 Dez. 2013
Hi!
Make a table like
tt = -5:5;
Access your variable with index -3 like
V(tt==-3)
PS: you should not double-post your questions.
  3 Kommentare
Simon
Simon am 13 Dez. 2013
What are x and b? Are these start and end of interval (-5 and 5)?
t = length(p);
y = 0;
z = 0;
N = t-1;
e = N:-1:0;
tt = x:b;
y = zeros(numel(tt), 1);
for C = (x:b);
for n = 1:N+1
y(tt==C) = y(tt==C) + p(n) * C^e(n);
end
end
Don't mix n (number of coefficients) with n (loop counter)! And see my order of the loops.
Patrick Allaglo
Patrick Allaglo am 13 Dez. 2013
Yes x and b are start and end of interval.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Data Type Conversion finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by