PLEASE POST MATLAB CODE 82 Cursive Spline Splines are a meth

PLEASE POST MATLAB CODE!

8.2 Cursive Spline

Splines are a method of interpolating data points. They result in a smooth interpolation that is relatively “cheap” to compute. Matlab has a method for creating and evaluate the resulting polynomials (spline) so you do not have to know the details. For a function y(x), (for example,sine) one can see that with very few points (try 5 points in [0,2]) one can very closely approximate the original functions. You can also approximate a “parametric curve” (x(t), y(t)) by using a spline for each of the functions separately and then plotting the resulting function y vs. x. Do this with (for example) your name written in cursive. Write your name on graph paper, place a few points for each of the letters (chose them “wisely”) and take down the coordinates of the points. In Matlab, create two vectors with these data and find the spline approximation to each of the functions (x(t) and y(t)). Plot the resulting y vs. x. Despite only using a few points for each letter, the resulting plot should be nice and smooth.

Take this to the next level: Write down many (all?) separate letters of the alphabet in script. Figure out a way to combine letters into words and then write code that takes as input a string, and creates as output the cursive-written word(s). Can your code be flexible enough to deal with the letters f, i, j, t, and x? You might want to use a “map” type container to hold your data (find help on that via help containers.Map).

Solution

Subject: manual algorithm for matrix multiplication [3X2]*[2X3]
From: Nasser M. Abbasi
Date: 28 Sep, 2012 22:47:43
Message: 2 of 4

Reply to this message
Add author to My Watch List
View original format
Flag as spam

On 9/28/2012 3:49 PM, Matt wrote:
> Having trouble coming up with a code that multiplies two matrices together.
>I can\'t just use matlab to directly multiply then, I have to come up with a loop.
> I am not sure how to implement a loop but doing something like this sum(X(1,:).*Y(:,1)\')
>gets the first element in the multiplied matrix correct.
>

Can you just implement it from the algorithm itself? C=A*B means C(i,j) is
adding the product of row i from A with column j from B ? something like:

----------------------------
A=[3 4 1;
    2 3 4];

B=[ 1 2 3;
     4 5 6;
     7 8 9];

[nRow1,nCol1]=size(A);
[nRow2,nCol2]=size(B);

if nCol1 ~= nRow2
    error(\'inner dimensions must match\');
end

C = zeros(nRow1,nCol2);

for i = 1:nRow1
     for j = 1:nCol2
         for k = 1:nCol1
             C(i,j) = C(i,j) + A(i,k)*B(k,j);
         end
     end
end

C
-------------------------

This gives

C =

     26 34 42
     42 51 60

To verify

A*B

ans =

     26 34 42
     42 51 60

--Nasser

Subject: manual algorithm for matrix multiplication [3X2]*[2X3]
From: Matt
Date: 29 Sep, 2012 18:57:07
Message: 3 of 4

Reply to this message
Add author to My Watch List
View original format
Flag as spam

\"Nasser M. Abbasi\" <nma@12000.org> wrote in message <k459eh$vtm$1@speranza.aioe.org>...
> On 9/28/2012 3:49 PM, Matt wrote:
> > Having trouble coming up with a code that multiplies two matrices together.
> >I can\'t just use matlab to directly multiply then, I have to come up with a loop.
> > I am not sure how to implement a loop but doing something like this sum(X(1,:).*Y(:,1)\')
> >gets the first element in the multiplied matrix correct.
> >
>
> Can you just implement it from the algorithm itself? C=A*B means C(i,j) is
> adding the product of row i from A with column j from B ? something like:
>
> ----------------------------
> A=[3 4 1;
> 2 3 4];
>
> B=[ 1 2 3;
> 4 5 6;
> 7 8 9];
>
> [nRow1,nCol1]=size(A);
> [nRow2,nCol2]=size(B);
>
> if nCol1 ~= nRow2
> error(\'inner dimensions must match\');
> end
>
> C = zeros(nRow1,nCol2);
>
> for i = 1:nRow1
> for j = 1:nCol2
> for k = 1:nCol1
> C(i,j) = C(i,j) + A(i,k)*B(k,j);
> end
> end
> end
>
> C
> -------------------------
>
> This gives
>
> C =
>
> 26 34 42
> 42 51 60
>
> To verify
>
> A*B
>
> ans =
>
> 26 34 42
> 42 51 60
>
> --Nasser
excellent.

Subject: manual algorithm for matrix multiplication [3X2]*[2X3]
From: Matt J
Date: 29 Sep, 2012 19:54:08
Message: 4 of 4

Reply to this message
Add author to My Watch List
View original format
Flag as spam

\"Matt\" wrote in message <k452ge$pso$1@newscl01ah.mathworks.com>...
> Having trouble coming up with a code that multiplies two matrices together. I can\'t just use matlab to directly multiply then, I have to come up with a loop. I am not sure how to implement a loop but doing something like this sum(X(1,:).*Y(:,1)\') gets the first element in the multiplied matrix correct.
=============

The only requirement is that a loop be involved? If so, why not as follows:

result=zeros(size(X,1),size(Y,2));

for ii=1:size(Y,2)

result(:,ii)=X*Y(:,ii);

end

PLEASE POST MATLAB CODE! 8.2 Cursive Spline Splines are a method of interpolating data points. They result in a smooth interpolation that is relatively “cheap”
PLEASE POST MATLAB CODE! 8.2 Cursive Spline Splines are a method of interpolating data points. They result in a smooth interpolation that is relatively “cheap”
PLEASE POST MATLAB CODE! 8.2 Cursive Spline Splines are a method of interpolating data points. They result in a smooth interpolation that is relatively “cheap”

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site