How to store intermediate result

I am doing RBF Implementation. I have 5 values in centerset. While the substraction operation gs=normdatval(1,1:4)-centerset(1,1:4) I want to store my result each time(5times) in different variables like g1,g2,g3,g4,g5.Please help

1 Comment

Please don’t!
Just keep them as an array. You can access them just as easily from a vector (or matrix) array as from different variables, and it’s much less confusing with an array.

Sign in to comment.

Answers (1)

Try this:
g1=normdatval(1,1:4)-centerset(1,1:4)
g2=normdatval(1,1:4)-centerset(1,1:4)
g3=normdatval(1,1:4)-centerset(1,1:4)
g4=normdatval(1,1:4)-centerset(1,1:4)
g5=normdatval(1,1:4)-centerset(1,1:4)
Though for any more than about that many, you're better off creating an array. And you certainly don't want to create hundreds of separately named variables in a loop. Why not? See the FAQ : http://matlab.wikia.com/wiki/FAQ#How_can_I_create_variables_A1.2C_A2.2C....2CA10_in_a_loop.3F

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Asked:

on 20 May 2014

Answered:

on 20 May 2014

Community Treasure Hunt

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

Start Hunting!