As my first attempt in designing a formulas question I did (in global variable scope):

n = 5;

A = [0:n];

But I get a syntax error for this. How can I generate a list like this?

Thanks

Ali

This discussion has been locked because a year has elapsed since the last post. Please start a new discussion topic.

As my first attempt in designing a formulas question I did (in global variable scope):

n = 5;

A = [0:n];

But I get a syntax error for this. How can I generate a list like this?

Thanks

Ali

Hello Ali,

I don't think you can directly build arrays of variable dimension, but it may be possible to do it using the various functions available.

However, there may be another way to approach your problem. Can you tell us more specifically what you are trying to do? Attach an XML file if possible.

I don't think you can directly build arrays of variable dimension, but it may be possible to do it using the various functions available.

However, there may be another way to approach your problem. Can you tell us more specifically what you are trying to do? Attach an XML file if possible.

Thanks Dominique,

I want to give a set of random number of points (between 4 to 8 points) to the students and ask them to find the least square line of them. So n would be the number of points. Having this, all the lists (like x's and y's of the points) should have this size.

I want to give a set of random number of points (between 4 to 8 points) to the students and ask them to find the least square line of them. So n would be the number of points. Having this, all the lists (like x's and y's of the points) should have this size.

Hello Ali,

A variable-sized dataset is a bit tricky in the calculations of the Formulas question, but I found a fairly simple solution. For displaying the dataset in the question text, I found it easier to use JavaScript.

A variable-sized dataset is a bit tricky in the calculations of the Formulas question, but I found a fairly simple solution. For displaying the dataset in the question text, I found it easier to use JavaScript.

Simple but effective solution Dominique! Thanks a lot.

I understood how the ternary operator was used. However I didn't really understand how you made the array to appear in the question text. This line:

\(\large{x}\hspace{40px}\)

I understood how the ternary operator was used. However I didn't really understand how you made the array to appear in the question text. This line:

\(\large{x}\hspace{40px}\)

how \large{x} gets printed to the array? and with the proper size? because x is fixed size of 8 in your global variable section...

Hello Ali,

<!-- p = Paragraph --> <p> Find the coefficients of the least regression line for the following data set: </p> <!-- div = Division. Text is centered --> <div style="text-align:center;"> <!-- span = Inline container. Contains x written in TeX --> <span> \(\large{x}\hspace{40px}\) </span> <!-- span = Inline container. Span element with id "xSet" Will be filled by JavaScript with the data set xSet --> <span id="xSet" style="font-family:monospace;"> </span> </div>

// The data set is used only in the text of the question // Fills the text content of the element with id "xSet", $("#xSet"), with the data set xSet $("#xSet").text(xSet);

Thanks Dominique, I see. Always have resisted to learn some html/javascript, but seems should do it finally!