How can I fill the array with values that user gave me, in one column need be from smaller to higher number, and in the second column need be from higher to smaller. Than display it. It needs looks like this for example:

tab

1 3

2 2

3 1

clear all;    
close all;
a = input('give a value ');
n = input('give n value ');
for (x=1:n-a)
tab = ;
end

I really don't idea how to do this, can someone help?

有帮助吗?

解决方案

Following your input statements, try something like this:

tab = [a:n; n:-1:a].';

Say n=3 and a=1, then you get the array you show in your question. For n=5 and a=2, you get what your comment requests.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top