Thread Subject: How to Rescale dimensions of a 3-D matrix?

Subject: How to Rescale dimensions of a 3-D matrix?

From: JULIE

Date: 17 Nov, 2009 23:28:02

Message: 1 of 6

Hello!

I have a 3-D array from which I need to rescale the X and Y dimension.

At the moment the limits of the Y dimension are given by 1 to 101.
I need to rescale the values of this dimension into limits of 1 and 1.1.
Thus starting with the second value of Y, I have to divide each element by 1000.

The limits of the X dimension are currently given by 1 and 28.
I need to rescale them into limits of 3 and 30. Thus I have to add 2 to every element of X.

Given the 3-D array Right_matrix(x,y,z), how do I do this in Matlab?

I would be really glad for your help.

Thanks

Julie

Subject: How to Rescale dimensions of a 3-D matrix?

From: Darren Rowland

Date: 18 Nov, 2009 02:16:20

Message: 2 of 6

Your explanation is a little confusing, could you elaborate a bit. Are you talking about the values in the array or are you talking about the size of the array? Or something else?

Subject: How to Rescale dimensions of a 3-D matrix?

From: JULIE

Date: 18 Nov, 2009 09:32:05

Message: 3 of 6

"Darren Rowland" <darrenjremovethisrowland@hotmail.com> wrote in message <hdvldk$35u$1@fred.mathworks.com>...
> Your explanation is a little confusing, could you elaborate a bit. Are you talking about the values in the array or are you talking about the size of the array? Or something else?

Hello!

I am not talking about the values inside the array, neither am I am talking about the size itself.

The original problem is the following:

I have a 3-D Plot: plot3(T), with T being a 2*2 matrix with several variations for the X and Y dimensions. I need to display the Ticks of all axes.


The Y-axis ranges from 1 to 100 and the Z-axis from 1 to 21.
For the X-Axis I do not want Matlab to display the numbers 1 to 100, increasing at 1.
I want Matlab to display the numbers 1 to 1.1, increasing at .001.
Thus I want to overwrite the existing Y-Ticks. I do NOT want to rescale the axis OR to simply display the interval 1 to 1.1. from the existing axis. The SET Xtick command does not work for this.

For the Z-Axis I do not want Matlab to display the numbers 1 to 21.
I want Matlab to display the numbers 3 to 24. AGAIN I want to overwrite the existing Ticks.

How can I do this????? I would be glad to figure this out, even if I have to change each single Tick manually via the Plot editor.

Thanks!

julie

Subject: How to Rescale dimensions of a 3-D matrix?

From: Jan Simon

Date: 18 Nov, 2009 12:00:24

Message: 4 of 6

Dear JULIE!

> I am not talking about the values inside the array, neither am I am talking about the size itself.
>
> I have a 3-D Plot: plot3(T), with T being a 2*2 matrix with several variations for the X and Y dimensions. I need to display the Ticks of all axes.
>
> The Y-axis ranges from 1 to 100 and the Z-axis from 1 to 21.
> For the X-Axis I do not want Matlab to display the numbers 1 to 100, increasing at 1.
> I want Matlab to display the numbers 1 to 1.1, increasing at .001.
> Thus I want to overwrite the existing Y-Ticks. I do NOT want to rescale the axis OR to simply display the interval 1 to 1.1. from the existing axis. The SET Xtick command does not work for this.
>
> For the Z-Axis I do not want Matlab to display the numbers 1 to 21.
> I want Matlab to display the numbers 3 to 24. AGAIN I want to overwrite the existing Ticks.
>
> How can I do this????? I would be glad to figure this out, even if I have to change each single Tick manually via the Plot editor.

I'm still more confused now.
You can set tickmarks with the "XTickLabel" property (same for Y and Z). This can be used in junction with setting the "XTick" and the strings of the labels can be chosen indepently from the real values.

But I think it would be much better to create the matrix (is it really [2 x 2]?!) with the correct dimension. E.g. instead of renaming the Z-labels, you can add 2 to the values of the matrix...

Good luck, Jan

Subject: How to Rescale dimensions of a 3-D matrix?

From: Darren Rowland

Date: 19 Nov, 2009 06:12:05

Message: 5 of 6

I agree with Jan that this is still confusing, however perhaps this is something like what you want

yticklab = get(gca,'YTickLabel'); % Get the current y-axis labels
ytickval = str2num(yticklab); % Convert to numbers

newytickval = ytickval*k; % Apply appropriate scaling or transformation

newyticklab = num2str(newytickval); % Convert back to strings
set(gca,'YTickLabel',newyticklab) % Set the new y-axis label

You can do the same thing for other axes.
Hth,
Darren

Subject: How to Rescale dimensions of a 3-D matrix?

From: JULIE

Date: 22 Nov, 2009 20:28:01

Message: 6 of 6

"Darren Rowland" <darrenjremovethisrowland@hotmail.com> wrote in message <he2njl$lq4$1@fred.mathworks.com>...
> I agree with Jan that this is still confusing, however perhaps this is something like what you want
>
> yticklab = get(gca,'YTickLabel'); % Get the current y-axis labels
> ytickval = str2num(yticklab); % Convert to numbers
>
> newytickval = ytickval*k; % Apply appropriate scaling or transformation
>
> newyticklab = num2str(newytickval); % Convert back to strings
> set(gca,'YTickLabel',newyticklab) % Set the new y-axis label
>
> You can do the same thing for other axes.
> Hth,
> Darren

Hello Darren!

THANK YOU SO MUCH!

This is exaclty what I was looking for!

Cheers

Julie

Tags for this Thread

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

rssFeed for this Thread

Contact us at files@mathworks.com