C programming: logarithmic index array [closed] - c

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
I'm trying to decimate a given vector with a logarithmic rule instead of a linear one.
e.g.:
The given vector has 100 elements. I want to reduce it to a vector of 10 elements that are the same elements of the starting vector taken with a logarithmic rule on the int interval [0,99].
I hope to be clear enough. Any help is appreciated !
Have a nice day !

In pseudo-code :
int n; // Length of subsampled array
for i:
new_array[i] = array[(int)(log(i)/log(n)*length(array))]
Is that what you are trying to do ?

Related

C How can I calculate an average of a list without loops? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
So I created a linked List in C using structs and it stores ints. My mission is to calculate the average of the values in the list without using recursion or loops.
I already have the list's item count I just need the sum.
Any ideas?
Simply have two varibles - count, total; Update them in Add and Delete.
When u want avg, just return total/count.
The list is not length bounded, but i found a solution.
I create a variable in the list's ateuct to save the sum of the list, and i change the sum of the list each time I add or remove a cell. When I want to calculate the sums I'll just divide the sum by the count.
Thank you anyway for your help :)

For Loops in C to print out individual ints. [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I want to print out each integer of an int individually using a for loop. I am doing this because I want to print things in between some of the single ints. So if the number was 4564, I want to print out 4 5 6 4. Is there a quick way to do this?
I know how to do it in java but I am new to C and am not sure.
Something like this shall help
while(num!=0) {
printf("%d", num%10); //your last digit, you can store it in an array of characters as well
num = num/10 ;
}
Note : you've got to reverse the order while using the digits

Displaying an array by using pointer techniques [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I want to display the contents of an array with type double that has a length of 5 without using the [ ] indexing . I can only use a for loop and pointer techniques.
How can you achieve that ?
Can anyone give me a brief explanation of pointers as I have no idea how to use them exactly ?
The array indexing operator is a shorthand for hiding pointer arithmetic.
So if you have an array like this:
double a[5];
Instead of using this expression:
a[1]
You can use this:
*(a + 1)

User input to an array [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
When using C programming language, I have no idea how to put a user input to an array.
I need to get integers from the user in from of:
printf("Enter numbers. Separate each by a comma: ");
How can I put each number into an array?
This is a very helpful link
Also look up this too for clarification on Console.Read & Console.Readline
Difference between Console.Read() and Console.ReadLine()?

Simple Reshape of a 9061x16 into 6x24x??x16 (4D). Data included, [MATLAB] [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
i have a matrix og 9061x16 i want to reshape to 6x24x??x16. currently the 9061x16 explains this: 16 is the amount of customers.. and 9061 is how much data each customer have.
What i want from the reshape:
since the data is collected every 10 min. for a duration of 62 days and some hours which the ?? is. Since in 1 hour there is collected 6 data. the matrix will therefore be like 6x24xdaysx16..
please do help i really need this :(.
the x.mat is what i reshaped 9061x16 from the V.mat
(The data can be downloaded from this post: Data of x.mat and v.mat
You could extend x to a number of rows multiple of 6*24, and then use reshape:
x(ceil(size(x,1)/144)*144, end) = 0; %// extend x, filling with zeros
x = reshape(x, 6, 24, [], 16); %// reshape x into desired form

Resources